Javascript Flashcards
(300 cards)
What is the purpose of variables?
a way to store values
How do you declare a variable?
var and its name
How do you initialize (assign a value to) a variable?
with the assignment operator = then semicolon ;
What characters are allowed in variable names?
The period, the underscore, and the characters $, #, and @
What does it mean to say that variable names are “case sensitive”?
capitalizing letters change the name
What is the purpose of a string?
assign text to a value
What is the purpose of a number?
to assign a value a number to manipulate
What is the purpose of a boolean?
assign a value as either true or false
What does the = operator mean in JavaScript?
assignment
How do you update the value of a variable?
use the name with a new value assigned
What is the difference between null and undefined?
null means intentionally left blank and undefined means there is no value assigned
Why is it a good habit to include “labels” when you log values to the browser console?
so you know what the value your seeing represents
Give five examples of JavaScript primitives.
undefined , null , boolean , string and number
What data type is returned by an arithmetic operation?
integer value
What is string concatenation?
adding strings together to combine them
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?
adds the value on the right to the variable on the left
What are objects used for?
containers for named values
What are object properties?
names that separate objects from others
Describe object literal notation.
an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last
How do you remove a property from an object?
use the delete operator before the object name
What are the two ways to get or update the value of a property?
bracket notation name[‘name2’], and dot notation name.name2
What are arrays used for?
when you want to store an ordered list of values