JavaScript Flashcards
What is the purpose of variables?
store and manipulate data in the future
How do you declare a variable?
var, const, or let
How do you initialize (assign a value to) a variable?
use = (assignment operator) after declaring the variable
What characters are allowed in variable names?
letters, dollar sign, underscore, numbers (not first character)
What does it mean to say that variable names are “case sensitive”?
uppercase and lowercase letters are considered different by the engine
What is the purpose of a string?
store/manipulate text content
What is the purpose of a number?
store/manipulate numbers with math
What is the purpose of a boolean?
logic with binary states, decision making
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
use assignment operator (variable = value)
What is the difference between null and undefined?
null is intentional emptiness (can’t exist unless assigned to variable), undefined is default value of variables
Why is it a good habit to include “labels” when you log values to the browser console?
understand what the log’s content contains
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
attach one string to another to create a new string
What purpose(s) does the + plus operator serve in JavaScript?
arithmetic addition, string concatenation if string is present
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
add/concatenate a value onto stated variable, then assign the result to the variable
What are objects used for?
storing related data within a single variable
What are object properties?
the “variables” contained within the object, key and value pair
Describe object literal notation.
curly braces containing properties, property : value
How do you remove a property from an object?
using the “delete” operator
What are the two ways to get or update the value of a property?
dot notation ( object.property ) / bracket notation ( object[‘property’] )
What are arrays used for?
storing related values within a single variable