JavaScript Flashcards
[JS Primitives and Variables]
What is the purpose of variables?
store temporary bits of information such as strings or numbers for future use
[JS Primitives and Variables]
How do youdeclarea variable?
keywords let, const, var and variable name
[JS Primitives and Variables]
How do you initialize (assign a value to) a variable?
using the equals operator ( = )
[JS Primitives and Variables]
What characters are allowed in variable names?
alphabet letters, numbers, dollar sign ($) and underscore (_)
numbers cannot be used as the first character
[JS Primitives and Variables]
What does it mean to say that variable names are “case sensitive”?
variable names have to be exactly the same, even capitalized letters
[JS Primitives and Variables]
What is the purpose of a string?
storing text which JS cannot read
[JS Primitives and Variables]
What is the purpose of a number?
for tasks involving counting or operations
[JS Primitives and Variables]
What is the purpose of a boolean?
for making decisions / choice (yes or no)
[JS Primitives and Variables]
What does the=operator mean in JavaScript?
assignment operator
[JS Primitives and Variables]
How do you update the value of a variable?
variableName = newValue;
[JS Primitives and Variables]
What is the difference betweennullandundefined?
null is a value that intentionally is nonexistent or invalid
undefined are variables that were not defined
[JS Primitives and Variables]
Why is it a good habit to include “labels” when you log values to the browser console?
to know what is being logged and when the log was called
[JS Primitives and Variables]
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
[JS Operators and Expressions]
What data type is returned by an arithmetic operation?
number
[JS Operators and Expressions]
What is string concatenation?
Adding two strings together
[JS Operators and Expressions] What purpose(s) does the + plus operator serve in JavaScript?
addition & concatenation
[JS Operators and Expressions]
What data type is returned by comparing two values (< , >, ===, etc)?
true or false (boolean)
[JS Operators and Expressions]
What does the += “plus-equals” operator do?
it adds to the original value and assigns the sum as the value
What value is given when trying to multiple, divide or subtract two strings?
NaN (not a number)
[JS Objects]
What are objects used for?
for storing variables and functions (that have similarities)
[CSS Objects]
What are object properties?
bits of information as variables about an object
[CSS Objects]
Describe object literal notation.
var obj = {
property: value,
property: value
}
[CSS Objects]
How do you remove a property from an object?
delete object.property
delete object[‘property’]
[CSS Objects]
What are the two ways to get or update the value of a property?
dot notation or bracket notation