JavaScript Flashcards
JavaScript Primitives and Variables:
What is the purpose of variables?
to store data for the future action/reference
JavaScript Primitives and Variables:
How do you declare a variable?
variable keyword
variable name ;
JavaScript Primitives and Variables:
How do you initialize (assign a value to )a variable?
(variable keyword
variable name)
assignment operator (=)
variable value ;
JavaScript Primitives and Variables:
What characters are allowed in variable names?
letters, dollar sign, underscore (only first three can start the variable name) and numbers (no dashes or periods)
JavaScript Primitives and Variables:
What does it mean to say that variable names are “case sensitive”?
it means that there’s a difference between a word starting with lowercase and that same word starting with a capital letter.
(bad practice to have same name using difference cases)
JavaScript Primitives and Variables:
What is the purpose of a string?
Strings are used when working with text
(typically used to add new content to a page and can contain HTML markup)
JavaScript Primitives and Variables:
What is the purpose of a number?
Numbers are used in tasks that involve counting or calculating sums
JavaScript Primitives and Variables:
What is the purpose of a boolean?
Booleans are used to determine which parts of a script should run.
Used to make decisions
JavaScript Primitives and Variables:
What does the = operator mean in JavaScript?
The equal sign means that you are going to assign a value to a variable
JavaScript Primitives and Variables:
How do you update the value of a variable?
variable name
assignment operator
and then the new value ;
JavaScript Primitives and Variables:
What is the difference between null and undefined?
null intentional absence of a value
undefined creates a variable but assigns it no value
JavaScript Primitives and Variables:
Why is it a good habit to include “labels” when you log values to the browser console?
If you do not include “labels” it can be confusing
JavaScript Primitives and Variables:
Give five examples of JavaScript primitives
number, string, boolean, null, undefined
JavaScript Operators and Expressions:
What data type is returned by an arithmetic operation?
numbers
JavaScript Operators and Expressions:
What is string concatenation?
the process of joining together two or more strings to create one new string
JavaScript Operators and Expressions:
What purpose(s) does the + plus operator serve in JavaScript?
the plus operator adds numbers together or concatenates
JavaScript Operators and Expressions:
what data type is returned by comparing two values (<, >, ===, etc)?
boolean
JavaScript Operators and Expressions:
What does the += “plus-equals” operator do?
it adds the value to the right of the operand to a variable and assigns the result to the variable
JavaScript Objects:
What are objects used for?
group together a set of variables and functions to create a model of something you recognize in the real world
JavaScript Objects:
what are object properties?
variables that give information about an object
JavaScript Objects:
Describe object literal notation.
{
key: value ,
}
JavaScript Objects:
How do you remove a property from an object?
delete operator followed by objectName.propertyName
(period is member operator)
JavaScript Objects:
What are the two ways to get or update the value of a property?
dot notation or square bracket notation
JavaScript Arrays:
What are arrays used for?
for lists of data where either the order of the list is extremely important or unimportant