Javascript Flashcards
What is the purpose of variables?
variables are used to store data that can be accessed later
How do you declare a variable?
a keyword (like var) then the name of the variable
How do you initialize (assign a value to) a variable?
variable name = (assignment operator) value
What characters are allowed in variable names?
letters, numbers, $, _
What does it mean to say that variable names are “case sensitive”?
variables spelled with the same characters but have differences in capitalization are considered different
What is the purpose of a string?
stores data containing a series of characters
What is the purpose of a number?
used for calculations, determining the size, movement, or time associated with something
What is the purpose of a boolean?
defines whether something is true or false, for decisions
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
variableName = new value
What is the difference between null and undefined?
null is the intentional absence of value
Why is it a good habit to include “labels” when you log values to the browser console?
labels provide context to whatever you log in the console
Give five examples of JavaScript primitives.
strings, numbers, booleans, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combining a string with another value to create a new string
What purpose(s) does the + plus operator serve in JavaScript?
adds numbers and concatenates strings
What data type is returned by comparing two values ( > , < , ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value to the right of the operator to the value on the left and assigns the result to the variable on the left
What are objects used for?
group together a set of related variables and functions
What are object properties?
variables that are part of an object
Describe object literal notation.
objectName = { property : value, … } ;
How do you remove a property from an object?
delete keyword followed by the objectName.propertyName
What are the two ways to get or update the value of a property?
dot or bracket notation
What are arrays used for?
arrays store a list of values that are related to each other