javascript Flashcards
What is the purpose of variables?
To store data
How do you declare a variable?
A variable keyword and then the variable name
How do you initialize (assign a value to) a variable?
Using the assignment operator (=)
What characters are allowed in variable names?
Letters, numbers, dollar sign, or an underscore
What does it mean to say that variable names are “case sensitive”?
You can reuse the same name with different capitalization
What is the purpose of a string?
Holding data in text form
What is the purpose of a number?
For tasks involving counting or calculating and to store numerical data
What is the purpose of a boolean?
To store data as either a yes or no (lightswitch); yes it should do this or no it should not
What does the = operator mean in JavaScript?
Assignment operator; Assign a value to a variable
How do you update the value of a variable?
Using the assignment operator
What is the difference between null and undefined?
Undefined is a type while null is an object; Undefined is a variable that has been declared but the value has not
Why is it a good habit to include “labels” when you log values to the browser console?
To help keep track of what you are console logging
Give five examples of JavaScript primitives.
String, number, undefined, null, boolean
What data type is returned by an arithmetic operation?
Numbers
What is string concatenation?
Combining two strings
What purpose(s) does the + plus operator serve in JavaScript?
To add numbers and concatenate strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
Concatenates and assigns the new value to the original variable
What are objects used for?
To store properties and their values. They are meant to model real world objects.
What are object properties?
They tell us about the object (such as the name of a hotel)
Describe object literal notation.
You create an object by defining the key value pairs and assign it to a variable var student = { name = Shawn }
How do you remove a property from an object?
Using the delete operator
What are the two ways to get or update the value of a property?
Dot notation & Bracket notation
What are arrays used for?
Lists