Javascript Flashcards
(115 cards)
What is the purpose of variables?
To store data to be accessed later.
How do you declare a variable?
Var keyword variable Name; (var quantity;)
How do you initialize (assign a value to) a variable?
Var keyword var Name = var value; (var quantity = 3;)
What characters are allowed in variable names?
Letters, number, dollar sign, or underscore
What does it mean to say that variable names are “case sensitive”?
Using the same variable name must have the same lowercase or uppercase letters.
What is the purpose of a string?
To store data made up of text
What is the purpose of a number?
To store numeric data / for tasks that involve counting or calculating
What is the purpose of a boolean?
To store true or false data / binary data.
What does the = operator mean in JavaScript?
Assignment
How do you update the value of a variable?
Variable name = new value;
What is the difference between null and undefined?
Null is intentionally left with no value and undefined is declared to variables that have not been assigned a value yet.
Why is it a good habit to include “labels” when you log values to the browser console?
To add a description of the variable/value being logged.
Give five examples of JavaScript primitives.
String, number, boolean, undefined, null.
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Adding a string value with another value
What purpose(s) does the + plus operator serve in JavaScript?
Adds one value to another
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
It adds the value of the var on the right to the current value of the var on the left which then equals the var on the left.
What are objects used for?
To store multiple pieces of data in one variable / to organize data
What are object properties?
Individual variables stored in an object.
Describe object literal notation.
Var keyword variable name holding the object = { };
How do you remove a property from an object?
Delete operator . property name; OR delete property[‘property name’];
What are the two ways to get or update the value of a property?
Dot notation and bracket notation
What are arrays used for?
To store a list of values. (mainly for similar data)