JavaScript Flashcards
What is the purpose of variables?
to store data values that can be used later
How do you declare a variable?
var variableName;
How do you initialize (assign a value to) a variable?
variableName = value;
What characters are allowed in variable names?
letters, underscore, dollar sign, numbers (but variable name cannot start with a number)
What does it mean to say that variable names are “case sensitive”?
variable names with different casing constitute different variables
What is the purpose of a string?
to store words, letters, and characters
What is the purpose of a number?
to store numeric values
What is the purpose of a boolean?
to store the value of true/false
What does the = operator mean in JavaScript?
assigns a value to a variable
How do you update the value of a variable?
= assignment operator
What is the difference between null and undefined?
null must be intentionally assigned to a variable, while undefined is automatically assigned when a variable was not assigned a value
Why is it a good habit to include “labels” when you log values to the browser console?
to make clear which variables are being logged and in what order
Give five examples of JavaScript primitives.
number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combines strings
What purpose(s) does the + plus operator serve in JavaScript?
addition for numbers and concatenation for strings
What data type is returned by comparing two values ( < , > , === , etc)?
boolean
What does the += “plus-equals” operator do?
adds the value of the operand to the variable and assigns the result to the variable
What are objects used for?
group together related variables and functions
What are object properties?
variables that are part of an object which have a unique key name and correlated value
Describe object literal notation.
object in curly braces { } each key separated from its value using a colon, each key/value pair separated by commas
How do you remove a property from an object?
delete objectName.propertyName;
What are the two ways to get or update the value of a property?
objectName.propertyName (dot notation) or objectName[“propertName”] (bracket notation)
What are arrays used for?
storing a list of values