JavaScript Flashcards
What is the purpose of variables?
used to store data
How do you declare a variable?
using variable keyword
How do you initialize (assign a value to) a variable?
using variable keyword, variable name, assignment operator, and value
What characters are allowed in variable names?
can contain letters, digits, underscores, $
What does it mean to say that variable names are “case sensitive”?
This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters (camelCase)
What is the purpose of a string?
datatype consists of
letters and other characters; store text data
What is the purpose of a number?
store numeric data
What is the purpose of a boolean?
used to create true/false statements.
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
reassignment; the var keyword would no longer be in the statement
What is the difference between null and undefined?
an undefined variable has been declared but not defined yet. null is an assigned value of nothing
Give five examples of JavaScript primitives.
number, strings, booleans, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
adding strings together
What purpose(s) does the + plus operator serve in JavaScript?
adds one value to another or concatenates strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
Addition assignment
What are objects used for?
group together related data to create a model
What are object properties?
unique named keys paired to values
Describe object literal notation.
made up of object name followed by key and value pairs wrapped in curly braces
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?
using dot notation or square brackets
What are arrays used for?
store a list of values
Describe array literal notation.
array name followed by the assignment operator then square brackets with values separated by commas