Javascript Flashcards
What is the purpose of variables?
Store data/information
How do youdeclarea variable?
Start with variable keyword (const, var, or let) follow by a variable name
How do you initialize (assign a value to) a variable?
Using the assignment operator ‘’=’
What characters are allowed in variable names?
dollarsign ($) and underscore (_), letters and numbers
What does it mean to say that variable names are “case sensitive”?
The cases matter. “one” is not the same as “One”
What is the purpose of a string?
To store text as values
What is the purpose of a number?
To store numeric values
What is the purpose of a boolean?
To show true or false
What does the=operator mean in JavaScript?
assign
• How do you update the value of a variable?
assign a new value to that variable
What is the difference betweennullandundefined?
null is intentionally empty, will be updated later. undefined means a value has been declared by has no value.
Why is it a good habit to include “labels” when you log values to the browser console?
it is much clearer which variables are being logged and in what order. Good for debugging
Give five examples of JavaScript primitives.
string, boolean, number, undefined and null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Process of joining together two or more strings
What purpose(s) does the+plus operator serve in JavaScript?
it can serve as an addition for arithmetic operators and a string operator for concatenation
What data type is returned by comparing two values (,===, etc)?
boolean
What does the+=”plus-equals” operator do?
adds values and then it re-assigns to same variable
What are objects used for?
grouping together a set of variables and functions with property values and methods; used to model real-life objects
What are object properties?
properties are variables that are part of an object; objects can store any data types
Describe object literal notation.
{}; opening and closing curly braces.
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?
dot and bracket notation
What are arrays used for?
used for storing lists of data, numerically indexed