Javascript Flashcards
What is the purpose of variables?
To temporarily store a value in a program
How do you declare a variable?
with the var keyword
How do you initialize (assign a value to) a variable?
with the assignment operator followed by a value
What characters are allowed in variable names?
letters, numbers(but not first), underscores, and dollar signs.
What does it mean to say that variable names are “case sensitive”?
each letter, undercase and lowercase, has a different ASCII value.
What is the purpose of a string?
to store words and shit
What is the purpose of a number?
to store number
What is the purpose of a boolean?
to store either a true or false value that will determine the outcome of certain decisions in your program.
What does the = operator mean in JavaScript?
it is the assignment operator that will assign a value to a variable.
How do you update the value of a variable?
by initializing it with no var keyword.
What is the difference between null and undefined?
null is an assigned blank value while undefined is a not yet defined value.
Why is it a good habit to include “labels” when you log values to the browser console?
it makes code reading easier
Give five examples of JavaScript primitives.
number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
combining strings with an addition sign
What purpose(s) does the + plus operator serve in JavaScript?
both adds numbers and concatenates strings
What data type is returned by comparing two values (, ===, etc)?
a boolean
What does the += “plus-equals” operator do?
it adds the value, or expression, to the right of the equals sign to value of the variable to the left and then assigns that value to the variable.
What are objects used for?
to store related data and put together a type of model of some sort.
What are object properties?
variables inside of an object
Describe object literal notation.
after var assignment opening curly brace followed by the key of the property then a colon then the value of that property. Each of those properties are separated by commas. End with a closing curly brace.
How do you remove a property from an object?
the delete keyword and the 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?
for lists that don’t need to be ordered