JavaScript Flashcards
What is the purpose of variables?
To store values to use later on
How do you declare a variable?
var name
How do you initialize (assign a value to) a variable?
var name = “xxxx”
What characters are allowed in variable names?
letters (uppercase, lowercase), $, underscore _ , numbers (can’t start with numbers)
What does it mean to say that variable names are “case sensitive”?
lower case and upper case are not exchangeable in variable name
What is the purpose of a string?
to store text
What is the purpose of a number?
to store numeric value
What is the purpose of a boolean?
to store binary values and make decisions
What does the = operator mean in JavaScript?
assignment operator (to put value in something)
How do you update the value of a variable?
name = new value (do not need to redeclare var after it’s been declared first time)
What is the difference between null and undefined?
null is an assigned value (intentional). undefined = empty
Why is it a good habit to include “labels” when you log values to the browser console?
to make it easier to debug
Give five examples of JavaScript primitives.
string, number, boolean, null, 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?
add numerical values or concatenate strings
What data type is returned by comparing two values (, ===, etc)?
Boolean - true or false
What does the += “plus-equals” operator do?
add onto current variable value
What are objects used for?
to store relevant data together (grouping)
What are object properties?
to store additional data relevant to objects
Describe object literal notation.
{
property : value
}
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
dot notation and bracket notation
What are arrays used for?
store multiple values