JavaScript Flashcards
What is the purpose of variables?
to store data/information
without variables, we wouldn’t know what information would pertain to what
see data that come together from the past
and preserve data for the future
How do you declare a variable?
var variable;
var is the “variable keyword”
and “variable” is the variable name
How do you initialize (assign a value to) a variable?
variable name = value (number boolean string null undefined);
What characters are allowed in variable names?
letters numbers underscores and dollar signs
What does it mean to say that variable names are “case sensitive”?
capitals and lower cases of the same letter are completely different
What is the purpose of a string?
give variables value of text
What is the purpose of a number?
hold numerical values we use it for math, predominately
What is the purpose of a boolean?
to compare values with true or false
booleans are for making decisions
What does the = operator mean in JavaScript?
The equals sign (=) is an assignment operator. It is how you
assign a value to the variable. The assignment operator makes it so variables will contain a value
How do you update the value of a variable?
variable = new value;
What is the difference between null and undefined?
null is intentionally empty
undefined means theres no value there (has not been assigned a value yet)
Why is it a good habit to include “labels” when you log values to the browser console?
immediate identifier
good for a reference point
Give five examples of JavaScript primitives.
number boolean string null undefined
What data type is returned by an arithmetic operation?
number data type
What is string concatenation?
appending one string to the end of another string
What purpose(s) does the + plus operator serve in JavaScript?
addition
concatenating strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
The plus-equals operator ( += ) adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.
What are objects used for?
to group together properties or data
What are object properties?
chunk of data attached to one of those pieces of information
Describe object literal notation.
inside curly braces properties: values, each property separated by commas
How do you remove a property from an object?
delete object.property
What are the two ways to get or update the value of a property?
dot notation and square brackets
What are arrays used for?
to store items with similar data types with a similar purpose; similar values in a list format. arrays are lists