JavaScript Flashcards
What is the purpose of variables?
Store bits of data.
How do you declare a variable?
create a variable using
var(variable keyword) then providing it a name quantity(variable name): var quantity;
How do you initialize (assign a value to) a variable?
By using the =(assignment operator) sign followed by the data.
What characters are allowed in variable names?
a-z, 0-9, $ and _
What does it mean to say that variable names are “case sensitive”?
You can have two variables with different cases that refer to different variables but use the same word.
What is the purpose of a string?
To store written text often times information about a user.
What is the purpose of a number?
Used to count the items of things or doing mathematical equations.
What is the purpose of a boolean?
Gives us the ability to make decisions.
What does the = operator mean in JavaScript?
It is the assignment operator.
How do you update the value of a variable?
use the variable name followed by = and the new value:
fullname = Kalen Cobb
What is the difference between null and undefined?
Null = used by a developer to denote future use
undefined is usually accidental and the computer is telling you it is undefined.
Why is it a good habit to include “labels” when you log values to the browser console?
So you can keep track of your output.
Give some examples of JavaScript primitives.
strings, numbers, booleans, null, undefined.
What datatype is returned by an arithmetic operation?
Number
What is string concatenation?
The conjoining of two or more strings together using the + operator.
What purpose(s) does the + plus operator serve in JavaScript?
Addition and Concatenation
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Addition Assignment
adds whatever is on the right side to the value of the variable and then the result of that expression is assigned to the variable.
What are objects used for?
A box to keep related stuff together
What are object Properties?
Another way to store data, exclusive to the specific variable
Describe object literal notation.
Properties and values nested inside curly braces.
How do you remove a property from an object?
delete operator (although this is rare)
What are the two ways to get or update the value of a property in JavaScript?
dot notation or bracket notation
What are arrays used for?
Storing lists of data