JavaScript Flashcards
What is the purpose of variables?
So the computer has a temporary location to store data.
How do you declare a variable?
With the keyword ‘var’.
How do you initialize (assign a value to) a variable?
By using the assignment operator. ( = )
What characters are allowed in variable names?
No special characters besides $ or _. No spaces.
What does it mean to say that variable names are “case sensitive”?
Name and name are two different variables.
What is the purpose of a string?
To store a sequence of characters. Can be used when working with any kind of text.
What is the purpose of a number?
For tasks that involve calculations.
What is the purpose of a boolean?
To help determine which part of a script should run.
What does the = operator mean in JavaScript?
The assignment operator in JavaScript means the data on the right is being assigned to the variable on the left.
How do you update the value of a variable?
By using the assignment operator.
What is the difference between null and undefined?
Null is intentionally assigned to no value;
While undefined has not yet been assigned a value.
Why is it a good habit to include “labels” when you log values to the browser console?
To make debugging easier.
Give five examples of JavaScript primitives.
Number, string, boolean, null, undefined, symbol, bigInt.
What data type is returned by an arithmetic operation?
Number.
What is string concatenation?
Combining two or more strings into one.
What purpose(s) does the + plus operator serve in JavaScript?
Addition and Concatenation.
What data type is returned by comparing two values (, ===, etc)?
Boolean.
What does the += “plus-equals” operator do?
Adds whatever number is on the right to the variable on the left, and then assigns that result to the variable.
What are objects used for?
To organize a set of variables and functions under one reusable item.
What are object properties?
A variable within an object.
Describe object literal notation.
Curly brackets with all properties and methods inside, separated by commas.
What are the two ways to get or update the value of a property?
Using dot or bracket notation.
How to you remove a property from an object.
The delete operator.
What are arrays used for?
To store ordered lists of data.