JavaScript Flashcards
What is the purpose of variables?
To store data(information) for a script.
How do you declare a variable?
You must declare the variable with a name. Providing a keyword (var) to declare a variable with a name.
How do you initialize (assign a value to) a variable?
You use the equal sign = (assignment)
What characters are allowed in variable names?
Letters, numbers (if it’s not the first character), $ or _
What does it mean to say that variable names are “case sensitive”?
Lowercase and uppercase letters are different.
What is the purpose of a string?
To hold a sequence of characters or text.
What is the purpose of a number?
For math and calculations.
What is the purpose of a boolean?
Conditional data type to determine if something is true or false.
What does the = operator mean in JavaScript?
It assigns things.
How do you update the value of a variable?
Use the variable name and assign it a new value.
What is the difference between null and undefined?
null is an intentional absence of value. Must be assigned.
undefined – javaScript says there’s nothing there.
Why is it a good habit to include “labels” when you log values to the browser console?
There’s no context as to what it is or where it came from without labels.
Give five examples of JavaScript primitives.
String, number, Boolean, null, undefined.
What data type is returned by an arithmetic operation?
numbers
What is string concatenation?
Combines multiple strings together.
What purpose(s) does the + plus operator serve in JavaScript?
Addition adds one value to another.
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
Adds the value to the right of the operand to a variable and assigns the result to the variable.
What are objects used for?
Group together a set of variables or properties and values to describe something. A collection of variables.
What are object properties?
Properties or variables that have a value within an object.
Describe object literal notation.
Assign an object literal to a variable. Within the object are names of properties and their corresponding values.
How do you remove a property from an object?
Delete operator Ex. delete pet.name
What are the two ways to get or update the value of a property?
Dot notation or bracket notation.
What are arrays used for?
Arrays store a list of values. Values can then be accessed if they are in a numbered list.