JavaScript Flashcards
What is the purpose of variables?
Variables are meant for storing values.
How do you declare a variable?
var variableName;
How do you initialize (assign a value to) a variable?
variableName = value;
What characters are allowed in variable names?
Alphabet characters, underscores, dollar signs, numbers (but not in the first char).
What does it mean to say that variable names are “case sensitive”?
name and Name are separate variables.
What is the purpose of a string?
To store lists of characters, useful for communicating information to humans or computers.
What is the purpose of a number?
To store numerical values for record keeping or calculation.
What is the purpose of a boolean?
Storing true/false values, used in control flow.
What does the = operator mean in JavaScript?
The right value is being assigned to the left variable.
How do you update the value of a variable?
varName = value;
What is the difference between null and undefined?
Null is intentional, undefined is usually not.
Why is it a good habit to include “labels” when you log values to the browser console?
So you know what’s being logged.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
Number.
What is string concatenation?
Putting two or more string values together to form a greater string
What purpose(s) does the + plus operator serve in JavaScript?
Arithmetic addition and concatenation.
What data type is returned by comparing two values?
Booleans.
What does the += “plus-equals” operator do?
Add what’s on the right to current value of variable then assign result to the variable.
What are objects used for?
Storing variables and functions associated with a particular entity.
What are object properties?
Values stored in an object.
Describe object literal notation.
var objNew = { prop1: value, prop2: value }
How do you remove a property from an object?
delete obj.property;
What are the two ways to get or update the value of a property?
Dot and bracket notation.
What are arrays used for?
Storing ordered lists of values.