JavaScript Flashcards
What is the purpose of variables?
To store data
How do you declare a variable?
Var variablename= variable value
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
Letter, $, or _, numbers after first character
What does it mean to say that variable names are “case sensitive”?
Variable name can be different for capital or lowercase same name
What is the purpose of a string?
Store text a sequence of characters
What is the purpose of a number?
Store a number, calculations
What is the purpose of a boolean?
Store true or false values, render a sate of something is or isn’t
What does the = operator mean in JavaScript?
Assignment operator, assigning a value to the variable.
How do you update the value of a variable?
Variablename = newvalue
What is the difference between null and undefined?
Null: value can only be assigned, not generated, developer set variable = null purposely. placeholder empty for now
Undefined: empty, nothing here
Why is it a good habit to include “labels” when you log values to the browser console?
To understand which console log is being output
Give five examples of JavaScript primitives.
Number, String, Boolean, Undefined, Null and Symbol
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Joining together 2 or more strings, result will be a string
What purpose(s) does the + plus operator serve in JavaScript?
cocatenate or add
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
The addition assignment (+=) operator adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
Grouping together related variables
What are object properties?
Piece of data stored in the object, collection of variables
The key and value in the objects
Describe object literal notation.
Var object = {
Key: value,
Key: value
};
How do you remove a property from an object?
Delete object.property
What are the two ways to get or update the value of a property?
Dot notation object.property
Bracket notation object[property]
What are arrays used for?
Lists of data where either order is important or not important