JavaScript Primitives and Variables Flashcards
What is the purpose of variables?
used for storing data with an identifier
How do you declare a variable?
using the keyword “var” and then an identifier
How do you initialize (assign a value to) a variable?
using “=” assignment operator
What characters are allowed in variable names?
all characters except for dash and period
What does it mean to say that variable names are “case sensitive”?
All variables are case sensitive, so score and Score would be different variable names, but it is bad practice to create two variables that have the same name using different cases.
What is the purpose of a string?
Strings are used for storing a series of text enclosed within quotation marks as data
What is the purpose of a number?
Used for counting or calculating
What is the purpose of a boolean?
Used for stating when something is true or false
What does the = operator mean in JavaScript?
assignment of a value
How do you update the value of a variable?
by assigning a value to the variable
What is the difference between null and undefined?
Null is basically a void or intentionally empty value while undefined is where a variable has not been assigned yet
Why is it a good habit to include “labels” when you log values to the browser console?
It is useful for describing whatever is being logged into the console
Give five examples of JavaScript primitives.
String, Numbers, Boolean, Null, undefined