JavaScript Flashcards
What is the purpose of variables?
to store or remember bits of information for the script.
How do you declare a variable?
variable keyword plus variable name (var, let, const)
How do you initialize (assign a value to) a variable?
with the assignment operator (=)
What characters are allowed in variable names?
letters, numbers, dollar sign or underscore
What does it mean to say that variable names are “case sensitive”?
that uppercase/lowercase letters are distinguished. score is not same as Score.
What is the purpose of a string?
to represent or manipulate text
What is the purpose of a number?
to represent or manipulate numbers for calculation.
What is the purpose of a boolean?
they allow us to make decisions in code. to determine if something is true or false.
What does the = operator mean in JavaScript?
assignment operator. assigns value to a variable.
How do you update the value of a variable?
variable name, equal sign, new value.
What is the difference between null and undefined?
null is purposeful emptiness; undefined is accidental emptiness.
Why is it a good habit to include “labels” when you log values to the browser console?
to make it clear which variables are 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?
joining two or more strings together to create a single value
What purpose(s) does the + plus operator serve in JavaScript?
addition for arithmetic and string concatenation for string.
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
The addition assignment operator (+=) adds the value of the right operand to a variable and assigns the result to the variable.
What are objects used for?
to group together a set of variables and function to create a model. to store multiple pieces of information that are related to each other.
What are object properties?
it’s the variable of the object. tells us about the object (name, number of rooms)
Describe object literal notation.
keyword var, object variable name, property key and value pairs.
How do you remove a property from an object?
use the operator ‘delete’ followed by dot or bracket notation.
What are the two ways to get or update the value of a property?
dot notation or square bracket notation
What are arrays used for?
to store a list or set of values that are related to each other