javascript-primitives-and-variables Flashcards
What is the purpose of variables?
To store values
How do you declare a variable?
By using Var
How do you initialize (assign a value to) a variable?
by using an equal operator
What characters are allowed in variable names?
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _
Names are case sensitive
Reserved words (like JavaScript keywords) cannot be used as names
What does it mean to say that variable names are “case sensitive”?
(y and Y are different variables)
What is the purpose of a string?
to assign string value
What is the purpose of a number?
To assign a number value
What is the purpose of a boolean?
To be used in the comparison operation
What does the = operator mean in JavaScript?
its an assignment operator
How do you update the value of a variable?
By assigning a different value
What is the difference between null and undefined?
undefined means a variable has been declared but has not yet been assigned a value.
null is an assignment value. It can be assigned to a variable as a representation of no value.
Why is it a good habit to include “labels” when you log values to the browser console?
It is easier for readability
Give five examples of JavaScript primitives.
undefined , null , boolean , string and number