JavaScript Flashcards
(201 cards)
What is the purpose of variables?
Let you store data in your program for later use or for modification
How do you declare a variable?
var variableName;
How do you initialize (assign a value to) a variable?
Equals sign
What characters are allowed in variable names?
First character: Letter, _, $
Other characters: Letter, _, $, Number
What does it mean to say that variable names are “case sensitive”?
Capital letters are different from lowercase letters
What is the purpose of a string?
A literal representation of characters (holds letters)
What is the purpose of a number?
Contains numerical data
What is the purpose of a boolean?
True/false logic
What does the = operator mean in JavaScript?
Assigns a value to a variable
How do you update the value of a variable?
Equals sign without var
What is the difference between null and undefined?
Undefined: the variable is declared but doesn’t have a value/hasn’t been assigned
Null indicates the variable has an empty or non-existent value, must be assigned
Why is it a good habit to include “labels” when you log values to the browser console?
Makes it easier and clearer to keep track of your variables
Give five examples of JavaScript primitives.
String, Number, Boolean, Null, Undefined
What is string concatenation?
Combining strings into a new string
What purpose(s) does the + plus operator serve in JavaScript?
Add numbers together or concatenate strings
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Adds the value on the right side to the variable and assigns the result to the variable
What are objects used for?
Storing multiple values in a single collection
Consolidating like data and modeling real world objects
What are object properties?
Essentially variables attached to an object
Describe object literal notation.
Object name {property name: value…}
How do you remove a property from an object?
Delete operator
What are the two ways to get or update the value of a property?
Dot notation or bracket notation
What are arrays used for?
Storing a list of values with a particular order
Describe array literal notation.
var newArrayName = [];