JavaScript Flashcards
What is the purpose of variables?
To store data
How do you initialize (assign a value to) a variable?
Assign a value after the assignment operator
What characters are allowed in variable names?
letters, numbers, dollar sign $, or an underscore _
What does it mean to say that variable names are “case sensitive”?
For the variable to be recognized, it needs to be entered with the same casing as it was when it was declared
What is the purpose of a boolean?
To determine if something is true or false, and to tell if script should run or not in conditionals
What does the = operator mean in JavaScript?
It is the assignment operator
How do you update the value of a variable?
Reassigning it without declaring it again, you can leave off the Var
What is the difference between null and undefined?
Null is intentional whereas undefined hasn’t been assigned yet
Give five examples of JavaScript primitives.
string, number, bigint, boolean, undefined, symbol, and null.
What is string concatenation?
joining together two or more strings to make a single value
What purpose(s) does the + plus operator serve in JavaScript?
addition for strings (concatenation) and numbers
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
Addition assignment, adds the values on both left and right operands
What are objects used for?
Group together a set of variables and functions to represent something such as a person or a car
What are object properties?
Variable within an object
Describe object literal notation.
Properties of the object are stored within curly braces
How do you remove a property from an object?
delete object.property
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
Describe array literal notation.
Putting the values of an array inside a bracket and separating each value with a comma.
How are arrays different from “plain” objects?
The key for each value in an array is a number. The number is the location in the array.
What number represents the first index of an array?
0
What is the length property of an array?
A method that returns how many values are in an array
How do you calculate the last index of an array?
array.length - 1