JavaScript Flashcards
What is the purpose of variables?
a stored data to use it later on
How do you declare a variable?
var const let
How do you initialize (assign a value to) a variable?
use the assignment operator (=)
What characters are allowed in variable names?
letters, $, _ (underscore); cannot start with number
What does it mean to say that variable names are “case sensitive”?
case should match
What is the purpose of a string?
used with any kind of text; add new content into a page
What is the purpose of a number?
used in calculations and size
What is the purpose of a boolean?
to make a binary decision (true/false)
What does the = operator mean in JavaScript?
value being assign to
How do you update the value of a variable?
name = new value (no need to put var const let, only at first)
What is the difference between null and undefined?
null is intentionally exists (purpose of emptiness for a moment)
undefined exists unintentionally
Why is it a good habit to include “labels” when you log values to the browser console?
helps to track what the value is for
Give five examples of JavaScript primitives.
number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
two or more strings used to create a single value
What purpose(s) does the + plus operator serve in JavaScript?
addition in numeric value or string value
What data type is returned by comparing two values (, ===, etc)?
boolean (true/false)
What does the += “plus-equals” operator do?
allow you to add on anything to current value of variable
What are objects used for?
stores property for variable
What are object properties?
makes what the variable different from other variables (unique)
Describe object literal notation.
opning curly brace for object literal, property, column, value, closing brace
How do you remove a property from an object?
delete operator (delete ___.____);
What are the two ways to get or update the value of a property?
using dot notation or bracket notation
What are arrays used for?
when you need to make a list with not knowing how many needs to be in