3/21 - 3/25/2022 Flashcards
What is the purpose of variables?
To store data
How do you declare a variable?
With a keyword “var, let, or const” and a variable name.
How do you initialize (assign a value to) a variable?
With the “=” assignment operator
What characters are allowed in variable names?
A letter, dollar sign ($), underscore (_), or a number. It cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
The lowercase and uppercase of variable names are considered.
For example, “case” and “Case” are different and would be interpreted differently by the browser/computer.
What is the purpose of a string?
To store text data
What is the purpose of a number?
To store numbers, perform mathematical calculations, and represent measurements
What is the purpose of a boolean?
To make decisions in code
What does the “=” operator mean in JavaScript?
The “=” operator is the assignment operator; it is used to assign values to variables in JavaScript.
How do you update the value of a variable?
You just assign it a new value using the same name and the “=” assignment operator.
What is the difference between null and undefined?
“null” means that something is nonexistent or has an invalid object or address. “null” is assigned intentionally to say that “nothing is here”.
“undefined” is a primitive value that is automatically assigned to a variable that have just been declared.
Why is it a good habit to include “labels” when you log values to the browser console?
It makes debugging easier because the labels help you keep track of which variable is which.
Give five examples of JavaScript primitives.
string, numbers, boolean, undefined, and null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
The process of joining two or more strings together to create one string.
What purpose(s) does the + plus operator serve in JavaScript?
The “+” operator can add numeric values or concatentate strings.
What data type is returned by comparing two values (, ===, etc)?
Booleans
What does the += “plus-equals” operator do?
It adds the current value of the variable (number or string) to the new variable (number or string) and re-assigns the result to the variable.
What are objects used for?
Objects are used to group together properties and methods(functions) to create a model of something that exists in the real world.
What are object properties?
Variable of an object
Describe object literal notation.
Object literal notation is comprised of the keyword used to create the variable, followed by the variable name for the object, followed by curly braces with content inside. The content is comprised of the properties and their respective values.
How do you remove a property from an object?
With the ‘delete’ keyword followed by the property of the object to be deleted using either dot or bracket notation.
What are the two ways to get or update the value of a property?
Using dot or bracket notation
What are arrays used for?
For storing list type data
Describe array literal notation.
Array literal notation consists of the variable declaration using a keyword (var, let, or const) followed by the assignment operator, followed by a set of brackets. The different data types (strings, numbers, arrays, objects) are stored inside the brackets separated by commas.
How are arrays different from “plain” objects?
Arrays are ordered lists that are zero-indexed, while objects are unordered.