js Flashcards
What is the purpose of variables?
store data; store value in variables that can be accessed; data that persists (accessible in the future; “data permanence”; saved for later)
How do you declare a variable?
using the keyword var
How do you initialize (assign a value to) a variable?
var keyword, name of the variable, assignment operator (equal sign), value of the variable
What characters are allowed in variable names?
letters, dollars, numbers (can’t start with a number), underscore
What does it mean to say that variable names are “case sensitive”?
required to match to function/work
What is the purpose of a string?
store data with text/series of characters; sequence of characters used to represent text
What is the purpose of a number?
numeric data type; 64 bits of memory
What is the purpose of a boolean?
logical data type that can have only the values true or false, i.e., boolean conditionals are often used to decide which sections of code to execute (such as in if statements) or repeat (such as in for loops); make decisions (do or don’t; yes or no)
What does the = equal sign operator mean in JavaScript?
assigning a value or something
How do you update the value of a variable?
reassign with new value
Why is it a good habit to include “labels” when you log values to the browser console?
debugging purposes; gives context to what data types you are working with
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null, symbol (produces an anonymous, unique value), bigint (aka long arithmetic, numeric data type; allows to process much greater numbers than can be fit in standard data types); all primitives are immutable (can’t be altered), that is not an object or method
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combination of two or more string values; can include concatenating to a number
What purpose(s) does the plus operator serve in JavaScript?
math or concatenation
What data type is returned by comparing two values (< less than, > greater than, === strictly equal, etc)?
boolean
What does the += “plus-equals” operator do?
adds to the value to the right to the value to the left and the result is the new value
What are objects used for?
data type; store various keyed collections and more complex entities
What are object properties?
association between name and value
Describe object literal notation.
a variable assigned to an object illustrated by opening and closing braces with properties and their respective values within; an array of key:value pairs
How do you remove a property from an object?
delete operator using the keyword delete and the object with it’s respective property value that you want to delete
What are the two ways to get or update the value of a property?
dot notation and bracket notation
What are arrays used for?
store data with a specific index; ordered
Describe array literal notation.
square brackets
How are arrays different from “plain” objects?
arrays are objects but objects aren’t arrays
What number represents the first index of an array?
0
What is the length property of an array?
array.length; number of entries in the array
How do you calculate the last index of an array?
array[array.length - 1]
What is a function in JavaScript?
type of object that can be called; set of reusable code