JavaScript Flashcards
(241 cards)
What is the purpose of variables?
To store data for use
How do you initialize (assign a value to) a variable?
variable name = (assignment operator) variable value;
What characters are allowed in variable names?
letters, dollar sign, underscore, numbers (cannot start with a number)
What does it mean to say that variable names are “case sensitive”?
variable with that same name but different casing is a different variable
What is the purpose of a string?
store and use text data
What is the purpose of a number?
store and use numeric data
What is the purpose of a boolean?
boolean is a data type with two values true/false can be used to for decision making
What does the = operator mean in JavaScript?
assignment operator, assigns value to a variable
How do you update the value of a variable?
variable name = (assignment operator) new value
What is the difference between null and undefined?
o undefined: computationally empty value and type are undefined o null: means nothing value is null type is object
Why is it a good habit to include “labels” when you log values to the browser console?
to see what is being logged and in what order
Give five examples of JavaScript primitives.
o string o number o boolean o undefined o null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Join two or more strings together
What purpose(s) does the + plus operator serve in JavaScript?
o Addition
o Concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value of the variable to the right operand and assigns the result to the variable i.e.:
x += y means: x = x + y
What are objects used for?
grouping related data variables (properties) and functionality functions(methods) together
What are object properties?
key: value pairs
data attached to a name, data may change, name will stay the same
a variable attached to a object
Describe object literal notation.
const/let objName = { } can include properties and methods
How do you remove a property from an object?
delete (keyword) object.(member operator)property
What are the two ways to get or update the value of a property?
o Dot notation object.(member operator)property/method = (assignment operator) value
o Bracket notation object[“property”] = (assignment operator) value
What are arrays used for?
storing a list of values
Describe array literal notation.
var keyword arrayName = (assignment operator) [value, value, value];