JAVASCRIPT Flashcards
(109 cards)
What is the purpose of variables?
to have data and store it to possibly use it later
make a piece of code mostly permanent
How do you declare a variable?
Using keywords such as “var, let, const”
How do you initialize (assign a value to) a variable?
using an equal sign (=)
What characters are allowed in variable names?
letters, numbers, dollar sign, or underscore (_)
cannot start a variable with a number
What does it mean to say that variable names are “case sensitive”?
case does not equal Case
What is the purpose of a string?
store text information
What is the purpose of a number?
numbers are for math
What is the purpose of a boolean?
to test for conditionals - only use the variable TRUE or FALSE
allows us to make a decision
without booleans –> you don’t get to do another way of branching others
What does the = operator mean in JavaScript?
assigning a value to a variable
How do you update the value of a variable?
assigning a new value on the same variable on a different line as long as the keyword, var was used because const cannot be changed because its constant
Don’t need another var on the next line. Just need to do variable = value
What is the difference between null and undefined?
Null –> indicator that it’s empty but plan to place something there –> purposeful emptiness –> declared by a developed –> needs to assign to a variable
undefined –> accidental emptiness –> declared by javascript language –> NEVER use this
Why is it a good habit to include “labels” when you log values to the browser console?
To ensure clarity and know what the value is assigned to. trying not to mistake that this value is not coming from another place.
Give five examples of JavaScript primitives.
string
number
boolean
null
undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Putting two or more strings together to form a phrase or a sentence
What purpose(s) does the + plus operator serve in JavaScript?
addition or concatenation
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
allows a number or string to add to the variable to the right and produces a single value
What are objects used for?
to group multiple variables and functions to describe something
to create a box that holds multiple variables that is related to each other
What are object properties?
individual property data within a data
Describe object literal notation.
has property:value pairs with a comma separating it
How do you remove a property from an object?
delete operator object.property
What are the two ways to get or update the value of a property?
dot notation or square bracket notation
object.property OR object[‘property’]
What are arrays used for?
to store any list of information – > order may be extremely important or may not be