JavaScript Flashcards
What is the purpose of variables?
to store data that we can access later
How do you declare a variable?
variable key word with variable name, var keyword
How do you initialize (assign a value to) a variable?
Assign a value after the assignment operator
var keyword name of variable = value
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”?
the same word lowercase and uppercase would be different variable names
What is the purpose of a string?
to add new content into a page
store date with text content
save a series of characters
What is the purpose of a number?
stores numeric value
count, math financial stuff, measurement of some sort
What is the purpose of a boolean?
data type two possible values
yes or no
make decisions
do or don’t do
What does the = operator mean in JavaScript?
assignment operator
assign value to variable
How do you update the value of a variable?
reassigning it without declaring it again, without the variable keyword
var unknown = null; first time only one unknown = 4 reassigning
What is the difference between null and undefined?
null is intentional -assigned as a value, do it on purpose
undefined no value hasn’t been assigned yet -nothing, empty
Why is it a good habit to include “labels” when you log values to the browser console?
to help you debug
Always put a label
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?
combine two strings or more to create one new string
What purpose(s) does the + plus operator serve in JavaScript?
adds one value to another or concatenation
used to join the strings on either side of it
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
addition assignment, adds the values on both left and right operands
What are objects used for?
to group together a set of variables and functions to represent something such as a person or a car
store data together, collection of stuff
What are object properties?
variable within an object
Describe object literal notation.
properties of the object are stored within curly braces
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 bracket notation
What are arrays used for?
it stores a list of values