Javascript Flashcards
(120 cards)
What is the purpose of variables?
To store values within them
How do you declare a variable?
var, let or const followed by variable name
How do you initialize (assign a value to) a variable?
Assignment operator =
What characters are allowed in variable names?
Letters, numbers, underscore, $
What does it mean to say that variable names are “case sensitive”?
Calling on the variable will require matching the case of all letters exactly
What is the purpose of a string?
Represents letters
What is the purpose of a number?
Represents numerical values
What is the purpose of a boolean?
Represents true or false, 1 or 0
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
variable = new value
What is the difference between null and undefined?
Null means there is no value whereas undefined means the value is not declared yet
Why is it a good habit to include “labels” when you log values to the browser console?
To see what you are logging
Give five examples of JavaScript primitives.
number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
Combining multiple string inputs
What purpose(s) does the + plus operator serve in JavaScript?
To concatenate strings or to add numbers
What data type is returned by comparing two values (<, >, ===, etc)?
Boolean values
What does the += “plus-equals” operator do?
Add and assign
What are objects used for?
To group variables and functions
What are object properties?
Keys and values
Describe object literal notation.
Declare variable = {key: value, key: value}
How do you remove a property from an object?
delete object.key
What are the two ways to get or update the value of a property?
Dot or bracket notation, pair with assignment operator if updating
What are arrays used for?
To have a list of items