JavaScript Flashcards
(120 cards)
What is the purpose of variables?
To store information
How do you declare a variable?
using var before the variable name
syntax
How do you initialize (assign a value to) a variable?
variableName = value
What characters are allowed in variable names?
alphabet, number, $ and _ (variable should not start with a number)
What does it mean to say that variable names are “case sensitive”?
uppercase and lowercase variable names are considered differently
What is the purpose of a string?
to store text information
What is the purpose of a number?
to store numbers
What is the purpose of a boolean?
to make a decision in a code (either true or false)
What does the = operator mean in JavaScript?
= means assigning value to a variable
How do you update the value of a variable?
variablename = newValue
What is the difference between null and undefined?
undefined variable means a variable has not been assigned any value by the user
null means variable is assigned by the user with a null value
Why is it a good habit to include “labels” when you log values to the browser console?
To know which variable is being printed is a console
Give five examples of JavaScript primitives.
number, string, boolean, symbol & bigint.
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
joining two separate strings to one
What purpose(s) does the + plus operator serve in JavaScript?
adding numbers or concating two or more string
What data type is returned by comparing two values (, ===, etc)?
Boolean data type
What does the += “plus-equals” operator do?
\+= means adding value and storing to same variable eg(variableName = VariableName + 'additionalString')
What are objects used for?
to store multiple data and different types of data
What are object properties?
variable store in object
Describe object literal notation.
eg {propert:value}
How do you remove a property from an object?
using delete operator followed by object.property
syntax (delete objectname.propertyname)
What are the two ways to get or update the value of a property?
dot notaion and bracket
eg
objectname.updateProperty = newValue
objectname[‘updateProperty’] = newValue
What are arrays used for?
To store a list of data of similar type