JavaScript Flashcards
What is the purpose of variables?
To store information, so it can be retrieved later.
How do you declare a variable?
var name;
How do you initialize (assign a value to) a variable?
name = value;
What characters are allowed in variable names?
A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($). Subsequent characters can also be digits (0–9).
What does it mean to say that variable names are “case sensitive”?
Their exact case must match.
What is the purpose of a string?
To hold text.
What is the purpose of a number?
To hold information that relates to arithmetic calculations.
What is the purpose of a boolean?
To check whether a value is true or false and make decisions based on that.
What does the = operator mean in JavaScript?
Assigning a value.
How do you update the value of a variable?
name = newValue;
What is the difference between null and undefined?
Null has been set by the user, while undefined is on the computers end.
Why is it a good habit to include “labels” when you log values to the browser console?
So that you should be able to see clearly what relates to what, and also for the benefit of others.
Give five examples of JavaScript primitives.
number / string / boolean / undefined / null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
Adding a string to another string using +
What purpose(s) does the + plus operator serve in JavaScript?
Concatenation of strings / addition
What data type is returned by comparing two values (, ===, etc)?
Boolean.
What does the += “plus-equals” operator do?
Add new value, and reassigns to the variable.
What are objects used for?
To store properties and methods together.
What are object properties?
Like variables, they contain information about specifics of an object.
Describe object literal notation.
{ }
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
object.property / object[‘property’]
What are arrays used for?
To store lists.