JavaScript Flashcards
What is the purpose of variables?
store information for use later
How do you declare a variable?
var keyword eg var fullName
How do you initialize (assign a value to) a variable?
assignment operator =
What characters are allowed in variable names?
letters, numbers, dollar sign, underscore
What does it mean to say that variable names are “case sensitive”?
upper case and lower case are treated independntly. eg car is not the same as Car
What is the purpose of a string?
represent text
What is the purpose of a number?
represent numeric data type
What is the purpose of a boolean?
represent true or false
What does the = operator mean in JavaScript?
assignment eg var name = “jon”
How do you update the value of a variable?
variable name = (new value)
note that keyword var is not needed
What is the difference between null and undefined?
undefined is a primitive value automatically assigned to variables that have just been declared, or to formal arguments for which there are no actual arguments.
a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address.
Why is it a good habit to include “labels” when you log values to the browser console?
clarity in the output - makes it easier to identify.
A console log “label” is simply a short string that describes the variable or value being logged.
Give five examples of JavaScript primitives.
string, number, Boolean, undefined, null – bigint, symbol
What data type is returned by an arithmetic operation?
number
What is string concatenation?
joining together strings
What purpose(s) does the + plus operator serve in JavaScript?
addition and concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
addition assignment, adds value and assigns the result to the variable
What are objects used for?
group together a set of properties and methods
What are object properties?
tell us about the object
Describe object literal notation.
similar to css rulesets. var hotel = { name: "quay" }
How do you remove a property from an object?
delete keyword followed by the property name and object name
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?
storing a list of values that are related to each other