JavaScript Flashcards
What is the purpose of variables?
To store data or information or values.
How do you declare a variable?
Using the variable keywords such as: ‘var’, ‘let’, or ‘const’
How do you initialize (assign a value to) a variable?
by using the assignment operator =
What characters are allowed in variable names?
letters, numbers, $, _, capitol letters. Do not start with a number.
What does it mean to say that variable names are “case sensitive”?
upper case and lower case matters.
What is the purpose of a string?
to store text values
What is the purpose of a number?
to store numbers
What is the purpose of a boolean?
there are only 2 values, true or false
What does the = operator mean in JavaScript?
assigns a value to a variable
How do you update the value of a variable?
assign the variable a new value
What is the difference between null and undefined?
a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address.
undefined is a primitive value automatically assigned to variables that have just been declared, or to formal arguments for which there are no actual arguments.
Why is it a good habit to include “labels” when you log values to the browser console?
it is much clearer which variables are being logged and in what order.
Give five examples of JavaScript primitives.
strings, numbers, booleans, undefined, null
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
combining multiple strings into 1 string
What purpose(s) does the + plus operator serve in JavaScript?
to add numbers, or to concatenate strings
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds more to a variable then reassigns it. called addition assignment
What are objects used for?
Object group together variables and functions to create a model of something from the real world.
What are object properties?
variables inside an object
Describe object literal notation.
Name/key/property is separated from value by a colon.
Name/key/property-value pairs are separated by commas.
No comma follows the last name/key/property-value pair.
How do you remove a property from an object?
by using the delete keyword.
delete objectName.propertyName
What are the two ways to get or update the value of a property?
dot notation and bracket notation
What are arrays used for?
storing a list of values in a variable