Javascript Flashcards
What is the purpose of variables?
To hold values
How do you declare a variable?
var (name of var)
How do you initialize (assign a value to) a variable?
var (name of var) = value
What characters are allowed in variable names?
a-z, numbers, $, _
What does it mean to say that variable names are “case sensitive”?
The casing matters when trying to use variables
What is the purpose of a string?
To hold a collection of characters
What is the purpose of a number?
To hold numerical data
What is the purpose of a boolean?
To announce if a value is true or false. Likewise, it can announce 0 for false and 1 for true
What does the = operator mean in javascript
The assignment operator
How do you update the value of a variable?
re assign the value using the the name of the variable and = to new value
What is the difference between null and undefined?
Null is an object, but undefined is a type
Why is it a good habit to include “labels” when you log values to the browser console?
To identify what is being printed to the console.
Give 5 examples of JavaScript primitives
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
2 strings combine and become 1 string
What purpose(s) does the + plus operator serve in Javascript?
Increment by 1
What data type is returned by comparing two values?
boolean
What does the += operator do?
Combines the left with the right
What are objects used for?
A collection of data
What are object properties?
data fields of an object
Describe object literal notation.
When you declare the object’s properties literally
How do you remove a property from an object?
Delete
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What are arrays used for?
Collection of data