JavaScript ES5 Flashcards
What is the purpose of variables?
Store data for future access
How do you declare a variable?
var quantity;
How do you initialize (assign a value to) a variable?
quantity = 3;
What characters are allowed in variable names?
Letters
Numbers (cannot start with)
$
_
What does it mean to say that variable names are “case sensitive”?
Variables are stored with case sensitive names
What is the purpose of a string?
Represent text
What is the purpose of a number?
Mathematical operations
What is the purpose of a boolean?
Used with conditional logic to run specific blocks of code
What does the = operator mean in JavaScript?
Assignment operator assigns values to variables
How do you update the value of a variable?
let quantity = 3;
//reassign quantity = 7;
What is the difference between null and undefined?
null:
a non-existent value that is intentionally assigned by the user, usually a placeholder value
undefined:
a non-existent value that is automatically assigned by JavaScript if no value is given
Give five examples of JavaScript primitives.
Number String Boolean Null Undefined
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
Combination of at least one string value with another string value or primitive value
What purpose(s) does the + plus operator serve in JavaScript?
Addition
Concatenation
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Addition Assignment:
Adds the left value with the right value, and the result of this expression is reassigned to the left
What are objects used for?
Encapsulating characteristic data by key value pairs
What are object properties?
Variables inside of an object
Describe object literal notation.
var obj = {};
How do you remove a property from an object?
delete hotel.booked;
What are the two ways to get or update the value of a property?
Dot Notation:
vehicle.color = black
Bracket Notation:
vehicle[“color”] = “black”
What are arrays used for?
Store a list of numerically, zero based indexed data, where order may matter
Describe array literal notation.
var array = [];