JS primitives and variables Flashcards
What is the purpose of variables?
to store data types
How do you declare a variable?
using the key word var, let, or const
How do you initialize (assign a value to) a variable?
use the assignment (equal) operator
What characters are allowed in variable names?
numbers, letters, dollar signs, underscores
What does it mean to say that variable names are “case sensitive”?
capital letters and lower case letters are treated differently. If there are two variables with the same name, one with all capitals and the other with all lowercase (e.g. CAT and cat), they are considered two different variables.
What is the purpose of a string?
to store text values
What is the purpose of a number?
they are numeric values
What is the purpose of a boolean?
values that are either true or false
What does the = operator mean in JavaScript?
assigns a value to a variable
How do you update the value of a variable?
retyping the variable again and assigning a different value to it
What is the difference between null and undefined?
- null is an unknown value
- undefined has not been assigned a value
Why is it a good habit to include “labels” when you log values to the browser console?
labels help give more information about what you’re logging to the console; helps with debugging and to see if your code is working the way it should
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null