JavaScript Flashcards
What is the purpose of variables?
To store bits of data
How do you declare a variable?
With a variable keyword (var, let, const) followed by the variable name
How do you initialize (assign a value to) a variable?
With an assignment operator (=)
What characters are allowed in variable names?
letters, digits, underscores and dollar signs (CANNOT START WITH NUMBER)
What does it mean to say that variable names are “case sensitive”?
upper and lowercase matter
What is the purpose of a string?
To store text data
What is the purpose of a number?
To store number data
What is the purpose of a boolean?
To identify true or false
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
By calling again with the assignment operator followed by the new value
What is the difference between null and undefined?
Null usually a placeholder
Undefined points at valueless variables
Why is it a good habit to include “labels” when you log values to the browser console?
Describes the variable or value being logged
Give five examples of JavaScript primitives.
String
Boolean
Object
Undefined
Null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
When two or more lines of strings are combined using the addition operator
What purpose(s) does the + plus operator serve in JavaScript?
Adds one value to another
What data type is returned by comparing two values (<, >, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
To represent real world objects
What are object properties?
Information about the object
How do you remove a property from an object?
With the delete operator
What are the two ways to get or update the value of a property?
Dot and Bracket notation
What are arrays used for?
To store list data
Describe array literal notation.
var arrayName = [’’]