JavaScript Flashcards
What is the purpose of variables?
to store information
How do you declare a variable?
by using a variable keyword following 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?
all letters
What does it mean to say that variable names are “case sensitive”?
it has to be spelled exactly the same
What is the purpose of a string?
it can store letters and other characters
What is the purpose of a number?
- stores number
- for tasks that include counting or calculating, also controlling loops
What is the purpose of a boolean?
stores a value of either true or false
helpful to determine which part of the script should run
What does the = operator mean in JavaScript?
assignment operator say that you are going to assign a value to a variable
How do you update the value of a variable?
using the assignment operator
What is the difference between null and undefined?
null is an assigned value and undefined means the var has been declared but not defined
Why is it a good habit to include “labels” when you log values to the browser console?
you can start debugging or clarity
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?
joins the string variables being used
What purpose(s) does the + plus operator serve in JavaScript?
for addition and concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
it places the original variable in front what is being added
What are objects used for?
used to store data that correspond with one another
What are object properties?
key value pair
Describe object literal notation.
the object is the curly braces and their contents (property, values, methods)
How do you remove a property from an object?
use the delete operator
What are the two ways to get or update the value of a property?
dot notation , bracket notation
What are arrays used for?
storing a list of values