JavaScript Flashcards
What is the purpose of variables?
to store information
How do you declare a variable?
var name
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
letters number _ $
cannot start with a number
What does it mean to say that variable names are “case sensitive”?
letters have to match so the comp understands
What is the purpose of a string?
to store word or sentences
What is the purpose of a number?
to store numbers
What is the purpose of a boolean?
true or false
What does the = operator mean in JavaScript?
assigned
How do you update the value of a variable?
the var name and assignment op then the new value
What is the difference between null and undefined?
null means nothing. undefined means a variable has been declared but not defined yet.
Why is it a good habit to include “labels” when you log values to the browser console?
to help with debugging and to see what your console is logging
Give five examples of JavaScript primitives.
undefined , null , boolean , string and number
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
to combine strings together
What purpose(s) does the + plus operator serve in JavaScript?
adds values together
What data type is returned by comparing two values (, ===, etc)?
a Boolean
What does the += “plus-equals” operator do?
adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.
What are objects used for?
to holds multiple values..
they are used to model real world objects
What are object properties?
a property is an association between a name (or key) and a value. A property’s value can be a function, in which case the property is known as a method
Describe object literal notation.
var example = { }
How do you remove a property from an object?
delete keyword
What are the two ways to get or update the value of a property?
bracket or dot notation
What are arrays used for?
lets you store multiple values in a single variable.