javascript-primitives-and-variables Flashcards
What is the purpose of variables?
To assign and store values
How do you declare a variable?
Keyword ‘var’ variable = variable value
How do you initialize (assign a value to) a variable?
With an equals sign
What characters are allowed in variable names?
Letter, dollar sign, underscore. Can’t use - or . can’t use reserved keywords
What does it mean to say that variable names are “case sensitive”?
It’s case sensitive
What is the purpose of a string?
To describe anything within quotes, store any collection of characters as a singular thing.
What is the purpose of a number?
Describes a value
What is the purpose of a boolean?
True and false; like a light switch, to represent binary data… conditional statements.
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
Simply assign it a different value
What is the difference between null and undefined?
Undefined means no variable value has been given, null is an intentional empty value.
Why is it a good habit to include “labels” when you log values to the browser console?
To tell with debugging
Give five examples of JavaScript primitives.
String, number, boolean, undefined, null