JavaScript Flashcards
What is the purpose of variables?
To contain information for use later
How do you declare a variable?
var, let, or const. var variable = blank;
How do you initialize (assign a value to) a variable?
you use the assignment operator.
“=”
What characters are allowed in variable names?
numbers, _ , $.
You can use numbers, but you cannot start with them.
What does it mean to say that variable names are “case sensitive”?
To access a variable, you need to use the exact letter case used in the variable name
What is the purpose of a string?
A string holds text values.
What is the purpose of a number?
A number value can be used for expressions and calculations
What is the purpose of a boolean?
Boolean gives you true and false options. It allows your code to diverge.
What does the = operator mean in JavaScript?
This is the assignment operator. It sets one thing equal to another.
How do you update the value of a variable?
You assign a new value to the variable
What is the difference between null and undefined?
Null is a purposefully void value, while an undefined variable hasn’t been assigned a value yet.
Why is it a good habit to include “labels” when you log values to the browser console?
labels help you keep track of your console.
Give five examples of JavaScript primitives.
string, number, bigint, boolean, undefined, symbol, and null.
What data type is returned by an arithmetic operation?
a number value
What is string concatenation?
when you intermix strings with variable names using the + sign
What purpose(s) does the + plus operator serve in JavaScript?
It allows you to add values
What data type is returned by comparing two values (, ===, etc)?
false or true. A boolean
What does the += “plus-equals” operator do?
plus equals, take the current value and adds the new value to it
What are objects used for?
Objects are used to to transfer info by name
What are object properties?
the association between name and value
Describe object literal notation.
var name = {
first: Jacob,
last: Stone
};
How do you remove a property from an object?
your use the delete operator
What are the two ways to get or update the value of a property?
bracket or dot notation
What are arrays used for?
to hold lists or ordered values that can be indexed
Describe array literal notation.
var name = {
“Jacob”,
“Stone”
};
How are arrays different from “plain” objects?
it can be indexed
What number represents the first index of an array?
0
What is the length property of an array?
the amount of indexes in an array total
How do you calculate the last index of an array?
array[array.length-1]