JavaScript Flashcards
What is the purpose of variables?
To contain information for use later
How do you declare a variable?
var, let, or const. var variable = blank;
How do you initialize (assign a value to) a variable?
you use the assignment operator.
“=”
What characters are allowed in variable names?
numbers, _ , $.
You can use numbers, but you cannot start with them.
What does it mean to say that variable names are “case sensitive”?
To access a variable, you need to use the exact letter case used in the variable name
What is the purpose of a string?
A string holds text values.
What is the purpose of a number?
A number value can be used for expressions and calculations
What is the purpose of a boolean?
Boolean gives you true and false options. It allows your code to diverge.
What does the = operator mean in JavaScript?
This is the assignment operator. It sets one thing equal to another.
How do you update the value of a variable?
You assign a new value to the variable
What is the difference between null and undefined?
Null is a purposefully void value, while an undefined variable hasn’t been assigned a value yet.
Why is it a good habit to include “labels” when you log values to the browser console?
labels help you keep track of your console.
Give five examples of JavaScript primitives.
string, number, bigint, boolean, undefined, symbol, and null.
What data type is returned by an arithmetic operation?
a number value
What is string concatenation?
when you intermix strings with variable names using the + sign