JavaScript Flashcards
What is the purpose of variables?
stores values and updates values, also gives value permanence (don’t have to keep declaring variable value)
How do you declare a variable?
var varname;
How do you initialize (assign a value to) a variable?
assignment operator (=)
What characters are allowed in variable names?
can start with: $, _, letters
can contain: $, _, letter, numbers
What does it mean to say that variable names are “case sensitive”?
javascript distinguishes between lower and upper cased letters
What is the purpose of a string?
pass around characters not to be interpreted as code (text content)
What is the purpose of a number?
math
What is the purpose of a boolean?
store true/false values, used for decision making (this or that)
What does the = operator mean in JavaScript?
putting a value into something
How do you update the value of a variable?
reassign variable value
variablename = newvalue
What is the difference between null and undefined?
both return/represent nothing/emptiness,
null: intentional nothingness (null is an assigned value), typically temporary space holder to be filled later
undefined typically unused by developers - usually a return from the console signifying the value has been deleted or was not assigned a value
Why is it a good habit to include “labels” when you log values to the browser console?
gives a point of reference
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
adds strings/numbers together to one larger string
What purpose(s) does the + plus operator serve in JavaScript?
arithmetic operation and string concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value and assigns the sum to the variable
What are objects used for?
area to store related properties
What are object properties?
variables within objects (/associated with objects)
Describe object literal notation.
curly braces + properties and values + object name
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 or bracket notation
object.property
object[‘property’]
bracket notation allows the text within to be interpreted by javascript (eg you can use variable names)
What are arrays used for?
ordered lists