js primitives and variables Flashcards
What is the purpose of variables?
store data
How do you declare a variable?
var keyword (or let)
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
letters, numbers, $, _ (can’t start with a number)
What does it mean to say that variable names are “case sensitive”?
capitalization matters; variableName is NOT the same as variablename
What is the purpose of a string?
store text in a variable
What is the purpose of a number?
store numeric values in variables
What is the purpose of a boolean?
situations with 2 possible values (true/false, yes/no, on/off)
What does the = operator mean in JavaScript?
assignment
How do you update the value of a variable?
re-assign using =
What is the difference between null and undefined?
undefined is a default value if one hasn’t been declared, null is used intentionally often as a placeholder
Why is it a good habit to include “labels” when you log values to the browser console?
to identify/differentiate the console.logs
Give five examples of JavaScript primitives.
strings, numbers, boolean, null, undefined, objects, arrays (technically objects?)