JavaScript Flashcards
(165 cards)
What is the purpose of variables?
Lets us store values and be reusable
How do you declare a variable?
Use keyword var
How do you initialize (assign a value to) a variable?
Use variable name and assignment operator
What characters are allowed in variable names?
Letters, numbers, underscore, dollar sign (cant start with number)
What does it mean to say that variable names are ‘case sensitive’?
Two variable names that are the same letters but with different capitalization
What is the purpose of a string?
Stores text values
What is the purpose of a number?
Stores numeric values
What is the purpose of a boolean?
Stores TRUE or FALSE. Allows for logic and decisions
What does the = operator mean in JavaScript?
The assignment operator
How do you update the value of a variable?
Assign it to a value again, no keyword at the start
What is the difference between null and undefined?
Null is intentionally absent of a value, also an object
Undefined is lack of value since nothing has been done there
Why is it a good habit to include “labels” when you log values to the browser console?
Helps with debugging and context in what we will see in the console
Give 5 examples of JavaScript primitives.
- String
- Boolean
- Number
- Undefined
- Null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
Using a + to add two or more strings together
What purpose(s) does the + plus operator serve in JavaScript?
It can either add numbers together or concatenate strings into one string
What data type is returned by comparing 2 values ( <, >, ===, etc.)?
Boolean
What does the += “plus-equals” operator do?
It concatenates the strings and returns the expression as a string
What are objects used for?
Objects group together related variables and functions into a single object
What are object properties?
Properties are like variables that are part of an object. They store values like numbers, strings, booleans, arrays, and objects
Describe object literal notation.
A way to create an object
Start with curly braces, then property/method that is paired with a value/function. Use commas to separate those key/value pairs
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 or bracket notation
What are arrays used for?
Stores list-like info