JavaScript Flashcards
What is the purpose of variables?
The purpose of variables is to store a value.
How do you declare a variable?
A variable is declared with the const, var, or let keyword along with a name. e.g. ‘var test’.
How do you initialize (assign a value to) a variable?
To initialize a variable you use the = operator. e.g. ‘var test = ‘test’ ‘.
What characters are allowed in variable names?
The characters used must be a letter, underscore, or $.
What does it mean to say that variable names are “case sensitive”?
Variables are distinguished by their capitalization. e.g. ‘var Test’ and var test’ are different variables.
What is the purpose of a string?
A string is used to store a sequence of characters.
What is the purpose of a number?
A number is used to store numeric values.
What is the purpose of a boolean?
A boolean is used to store a true/false value.
What does the = operator mean in JavaScript?
The = operator is the assignment operator. It assign a value to a variable.
How do you update the value of a variable?
To update a variable you call the variable along with a new value. e.g. ‘test = ‘hi’.
What is the difference between null and undefined?
The Null type is purposely defined, while undefined is typically accidental.
Why is it a good habit to include “labels” when you log values to the browser console?
Adding labels to console log makes it easier to distinguish where the value is coming from.
Give five examples of JavaScript primitives.
The JavaScript primitives are: Number, String, Boolean, undefined, BigInt, and Symbol.
What data type is returned by an arithmetic operation?
Numeric data is returned by an arithmetic operation.
What is string concatenation?
String concatenation is joining strings by using the + operator. e.g. ‘var test = ‘hi ‘ + ‘name’ will return ‘hi name’.