JavaScript Flashcards
What is the purpose of variables?
variables store primitives like numbers, strings and boolean
How do you declare a variable?
var keyword
How do you initialize (assign a value to) a variable?
equal sign
What characters are allowed in variable names?
$, _, letters and digits
Must start with a letter, $ or _
What does it mean to say that variable names are “case sensitive”?
It means capitalized variable names and non-capitalized variable names are different
What is the purpose of a string?
It stores text
What is the purpose of a number?
It stores value
What is the purpose of a boolean?
It stores true or false
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
use assignment operator again
What is the difference between null and undefined?
undefined has been assigned but does not have a value. Null is intentionally left blank.
Why is it a good habit to include “labels” when you log values to the browser console?
for clarity and visibility
Give five examples of JavaScript primitives.
numbers, strings, boolean, null and undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
adding strings together
What purpose(s) does the + plus operator serve in JavaScript?
arithmetic and concatenation
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
addition operator
What are objects used for?
To store multiple properties in one variable name
What are object properties?
data of the object
Describe object literal notation.
starts with variable declaration followed by curly brackets with property names in them.
How do you remove a property from an object?
use delete operator
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What are arrays used for?
To keep lists of data and access them