JavaScript Flashcards
What is the purpose of variables?
To store/see data that came together from the past & preserve data to use in the future
How do you declare a variable?
By using let, const or var
How do you initialize (assign a value to) a variable?
By using the assignment operator to give it value
What characters are allowed in variable names?
Letter
Underscore
$
numbers (but it cannot be the first character)
What does it mean to say that variable names are “case sensitive”?
Capitalized and lowercase letters mean different things
What is the purpose of a string?
To store a series of characters
What is the purpose of a number?
To perform math
To represent numeric values
What is the purpose of a boolean?
To make decisions
What does the = operator mean in JavaScript?
To make it hold/contain a value
How do you update the value of a variable?
By assigning a new value
What is the difference between null and undefined?
Null is intentional absence/emptiness
Undefined means there is no value assigned
Why is it a good habit to include “labels” when you log values to the browser console?
To make it easy to know which value the console is printing
Give five examples of JavaScript primitives.
Boolean Null Number String Undefined
(and BigInt and Symbol)
What data type is returned by an arithmetic operation?
Numeric/number
What is string concatenation?
To join/append strings
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 (x === x, etc)?
Boolean
What does the += “plus-equals” operator do?
Adds the value on the right side of the operator to the variable and assigns the result back to the variable
What are objects used for?
To group together a set of properties and methods
What are object properties?
Chunk of data attached to objects
Describe object literal notation
var variableName = {
key : value,
key : value
}
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?
By using dot notation or square brackets
What are arrays used for?
For storing a list of values
Describe array literal notation
arrayname[‘value’, ‘value’];
How are arrays different from “plain” objects?
There is an order
They are numerically indexed
It keeps a count of the number of values in it
What number represents the first index of an array?
0
What is the length property of an array?
It’s a property that returns the number of values in that array