JavaScript Flashcards
What is the purpose of variables?
to store data that we can access later
How do you declare a variable?
variable key word with variable name, var keyword
How do you initialize (assign a value to) a variable?
Assign a value after the assignment operator
var keyword name of variable = value
What characters are allowed in variable names?
letters, numbers, dollar sign $, or underscore _
What does it mean to say that variable names are “case sensitive”?
the same word lowercase and uppercase would be different variable names
What is the purpose of a string?
to add new content into a page
store date with text content
save a series of characters
What is the purpose of a number?
stores numeric value
count, math financial stuff, measurement of some sort
What is the purpose of a boolean?
data type two possible values
yes or no
make decisions
do or don’t do
What does the = operator mean in JavaScript?
assignment operator
assign value to variable
How do you update the value of a variable?
reassigning it without declaring it again, without the variable keyword
var unknown = null; first time only one unknown = 4 reassigning
What is the difference between null and undefined?
null is intentional -assigned as a value, do it on purpose
undefined no value hasn’t been assigned yet -nothing, empty
Why is it a good habit to include “labels” when you log values to the browser console?
to help you debug
Always put a label
Give five examples of JavaScript primitives.
string, number, boolean, undefined, and null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combine two strings or more to create one new string