javascript-primitives-and-variables Flashcards
What is the purpose of variables?
To store bits of information
How do you declare a variable?
With the keyword var plus the variable name.
How do you initialize (assign a value to) a variable?
Variable name, plus assignment operator (=), plus value assigned to variable
What characters are allowed in variable names?
Letters, numbers, dollar sign, and underscore.
What does it mean to say that variable names are “case sensitive”?
It means that score and Score would be different variable names.
What is the purpose of a string?
They can be used when working with any kind of text.
What is the purpose of a number?
For tasks that involve counting or calculating sums.
What is the purpose of a boolean?
Check if something is true or false so we can make decisions.
What does the = operator mean in JavaScript?
It is an assignment operator. For when you are going to assign a value to a variable.
How do you update the value of a variable?
By assigning a new value to it.
What is the difference between null and undefined?
Null points, generally intentionally, to a nonexistent or invalid object or address.
undefined is a primitive value automatically assigned to variables that have just been declared, or to formal arguments for which there are no actual arguments.
Why is it a good habit to include “labels” when you log values to the browser console?
To make it more clear when debugging more than one console.log().
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null