JavaScript Flashcards
What is the purpose of variables?
to hold data that can used or referenced later
How do you declare a variable?
use the keywords var, const, and let and then the variable name
How do you initialize (assign a value to) a variable?
use the assignment operator =
What characters are allowed in variable names?
letters, $, _ , and numbers but numbers cannot be the first character
What does it mean to say that variable names are “case sensitive”?
var number and var Number are two different variables
What is the purpose of a string?
to store and manipulate text
What is the purpose of a number?
math, quantities, count things
What is the purpose of a boolean?
true or false values, booleans exist for decision making. this or that
What does the = operator mean in JavaScript?
assignment. giving value to a variable
How do you update the value of a variable?
refer to the variable again and give it a new value
What is the difference between null and undefined?
both carry empty values, but null is intentionally assigned - it’s organic. undefined is inorganic. it comes from JavaScript. Baked into the language.
Why is it a good habit to include “labels” when you log values to the browser console?
it will give us a point of reference
Give five examples of JavaScript primitives.
string, number, boolean, undefined, and null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combining two or more string values
What purpose(s) does the + plus operator serve in JavaScript?
adds numbers and concatenates strings
What data type is returned by comparing two values (<a>«/a>, <a>></a>, ===, etc)?</a>
boolean
What does the += “plus-equals” operator do?
take current value and addon whatever we stated and the result of that expression if the new value of the variable.
What are objects used for?
area to store data under one hood so everything is easier to access
What are object properties?
variables of the object
Describe object literal notation.
{
key: value,
key: value
}
How do you remove a property from an object?
delete keyword
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What are arrays used for?
to store values with order