JavaScript Flashcards
What are objects used for?
Objects allow us to put data that makes sense together in one group/container.
What are object properties?
Data stored in an object.
Describe object literal notation.
var objectName = {
property: value,
otherProperty: otherValue
}
How do you remove a property from an object?
Using the delete operator.
delete object.propertyName
What are the two ways to get or update the value of a property?
Dot Notation:
object.propertyName = “new value”
Bracket Notation:
object[‘properyName’] = “new value”
What is the purpose of variables?
Variables allow us to store data in memory to use later.
How do you declare a variable?
var variableName;
How do you initialize (assign a value to) a variable?
var variableName = value;
What characters are allowed in variable names?
letters, numbers (non-starting), $, _
What does it mean to say that variable names are “case sensitive”?
When calling a variable, it must be exactly the name of that variable with exact casing.
variable and Variable are different variables.
What is the purpose of a string?
What is the purpose of a number?
What is the purpose of a boolean?
Strings store text data
Numbers store numbers, used for measurements, etc.
Booleans store true or false, used for yes and no situations
What does the = operator mean in JavaScript?
Assignment
How do you update the value of a variable?
varName = updatedValue;
What is the difference between null and undefined?
Null is a value for purposely blank, undefined means a variable has not been assigned a value
Why is it a good habit to include “labels” when you log values to the browser console?
Labels give us context to what is being logged.
What data type is returned by an arithmetic operation?
number
What is string concatenation?
The joining of strings
What purpose(s) does the + plus operator serve in JavaScript?
Addition, concatenation of strings
What data type is returned by comparing two values (, ===, etc)?
Boolean, with values true or false
What does the += “plus-equals” operator do?
Adds the right side value to the left side variable and reassigns that new value to the left side variable
What are arrays used for?
Arrays are used for storing lists of similar data.
Describe array literal notation.
[firstItem, secondItem]
How are arrays different from “plain” objects?
Arrays have order, item keys are indices.
What number represents the first index of an array?
0, arrays are 0 indexed