JavaScript Flashcards
What is the purpose of variables
To store info to use later
How do you declare a variable?
let or var
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
Letters, Numbers, $, _
can’t start with numbers
variables are case sensitive
True
Purpose of strings?
store text
purpose of numbers?
calculations or adjusting CSS
purpose of a boolean?
true or false
what does the = operator mean?
assignment
how do you update the value of a variable?
variable name = new value
null vs undefined?
Nulls are set intentionally by the developer, whereas undefined is set by JS.
Null may indicate that a value will be assigned eventually.
Why is it a good habit to include “labels” when logging values.
Good for debugging.
5 examples of JS Primitives
String, number, Boolean, undefined, null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combining strings together into a new string
What purpose does the + plus operator serve in JavaScript?
Adds numbers together or concatenating strings
What data type is returned by comparing two values (, ===, etc.)?
Boolean
What does += do?
Adds a value onto a variable, and then stores that new value into the same variable.
Operant
Value that an operator is operating on
What are objects used for?
Grouping data that are related to eachother
What are object properties?
variables in an object
Describe object literal notation
Key value pairs separated by commas, stored between two curly brackets, and is assigned to a variable. Keys and values are separated with a colon.
How do you remove a property from an object?
Delete operator then use dot notation to choose the property or method