javascript-primitives-and-variables Flashcards
What is the purpose of variables?
Storing information.
How do you declare a variable?
Using the keyword “var”.
How do you initialize (assign a value to) a variable?
Using the “=” (assignment) operator.
What characters are allowed in variable names?
Letters, numbers, “$” and “_”.
What does it mean to say that variable names are “case sensitive”?
It means you can use lowercase and uppercase letters.
What is the purpose of a string?
To store characters or text.
What is the purpose of a number?
To store numbers (decimals and negatives as well).
What is the purpose of a boolean?
To determine if something is “true” or “false”.
What does the = operator mean in JavaScript?
Means assignment.
How do you update the value of a variable?
Assign a new value to the variable using the “var” keyword.
What is the difference between null and undefined?
Null is intentionally assigned, undefined is not intentionally and is the value of the variable when it is declared but no value has been passed to it.
Why is it a good habit to include “labels” when you log values to the browser console?
Makes your code easier to debug.
Give five examples of JavaScript primitives.
Numbers, booleans, strings, null and undefined.