JavaScript Flashcards
What is the purpose of variables?
they hold a value and preserve it for future use
How do you declare a variable?
var, let, const
How do you initialize(assign a value to) a variable?
=
What characters are allowed in variable names?
letters, numbers, $, _
What does it mean to say that variable names are “case sensitive”?
need to make sure casing is correct
What is the purpose of a string?
adds new text-value content into a page
What is the purpose of a number?
math use
What is the purpose of a boolean?
making decisions
What does the = operator mean in JavaScript?
making the variable contain value - assign value to a variable
How do you update the value of a variable?
variableName = new value;
What is the difference between null and undefined?
null: intentionally assign it as empty
undefined: does not exist yet
Why is it a good habit to include labels when you log values to the browser console?
To have an immediate reference to what exactly is being logged
Give 5 examples of JavaScript primitives:
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
joining together two or more strings to create one new string
What purpose does the + operator serve in JavaScript?
adds one value to another (math and concatenation)
What data type is returned by comparing two values (, ===, etc..)?
a boolean value - based on whether the comparison is true
What does the += operator do?
adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
Group together a set of properties and methods to create a model of something you would recognize in the real world
What are object properties?
key/value pairs
Describe object literal notation:
{
key: value (properties),
method: function() {}
};
How do you remove(delete) a property from an object?
delete object.property
What are the two ways to get or update the value of a property?
- dot notation
- square bracket syntax
What are arrays used for?
a list of values that are related to each other