JavaScript Flashcards
What is the purpose of variables?
To store pieces of data
How do you declare a variable?
With the var keyword (let,const)
How do you initialize (assign a value to) a variable?
Initialize a variable by assigning it to a value with an equal sign
What characters are allowed in variable names?
Dollar signs, underscores and letters
What does it mean to say that variable names are “case sensitive”
Variable names can be the same word but with different casings. Ex) var pRicE; and var Price; both work
What is the purpose of a string?
For storing and manipulating text
What is the purpose of a number?
Data type to represent and manipulate number values
What is the purpose of a boolean?
a True or false value for all javascript comparison and conditions
What does the=operator mean in JavaScript?
Assignment operator between the variable and data
How do you update the value of a variable?
Assign the variable to a new value; no declaration
What is the difference betweennullandundefined?
- Undefined is not assigned
- Null is an error,
Why is it a good habit to include “labels” when you log values to the browser console?
To confirm what type of data type you are working with, or what value is inside the variable
Give five examples of JavaScript primitives.
Number, boolean, string, null, undefined
What data type is returned by an arithmetic operation?
Depends. Going from left to right of the expression. It’ll work out the math operations then concatenate if a string is there.
What is string concatenation?
Adding two operands together with an addition operator
What data type is returned by comparing two values (,===, etc)?
A boolean value
What does the+=”plus-equals” operator do?
Adds the value on the right of the variable to the left of the operator. Then assigns the result to the variable
What are objects used for?
Allow a collection of data for a specific theme. Data organization
What are object properties?
Variable within an object literal
Describe object literal notation
Key value pairs within curly braces being assigned to a variable name
How do you remove a property from an object?
Using the “delete” operator
What are two ways to get or update the value of a property?
Using dot notation or you can use bracket notation
What are arrays used for?
To list out multiple values of similar data
Describe array literal notation
Square brackets with data divided by commas being assigned to a variable declaration