JavaScript Flashcards
What is the purpose of variables?
it can stores bits of information and can be reuse/recall at later time
How do you declare a variable?
var (keyword) nameOfVariable;
How do you initialize (assign a value to) a variable?
nameOfVariable = value;
What characters are allowed in variable names?
letters, numbers, dollar sign($) and underscore(_)
What does it mean to say that variable names are “case sensitive”?
same variable name with uppercase letter will result in another variable
What is the purpose of a string?
to store (text/character) letter, word or sentence
What is the purpose of a number?
to handle calculation or any tools that utilizes number
What is the purpose of a boolean?
to define whether something is true or false (for making decision)
What does the = operator mean in JavaScript?
Assigning / defining
How do you update the value of a variable?
by setting the variable to a new value
What is the difference between null and undefined?
Null = nonexistent or invalid value
Undefined = variable without value(argument)
Null = purposeful emptiness
Undefined = accidental emptiness
Why is it a good habit to include “labels” when you log values to the browser console?
because console.log only return value and it can be hard to keep track which variable it belongs to
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined, symbol, BigInt
What data type is returned by an arithmetic operation?
number
What is string concatenation?
adding second string(argument) behind the first string(argument)
What purpose(s) does the + plus operator serve in JavaScript?
mathematic + or concatenation
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
x += y -> x = x + y
Number + boolean = number
Number + string = string
Number + number = number
string + string = string
string + boolean = string
boolean + boolean = number
What are objects used for?
group together variables and function that are related
What are object properties?
variable & value [key], individual pieces of name and data
Describe object literal notation.
var varName = { (property) var: value, var2: value, (method) key: function }
How do you remove a property from an object?
delete object.key
What are the two ways to get or update the value of a property?
object.key or object[‘key’]
What are arrays used for?
to store list of data/information