Javascript Flashcards
(89 cards)
What is the purpose of variables?
storing data
How do you declare a variable?
Var name =
How do you initialize (assign a value to) a variable?
assignment operator
What characters are allowed in variable names?
number, text, $, _ cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
capitalizing letters will affect the variable.
What is the purpose of a string?
To add any kind of text.
What is the purpose of a number?
for tasks relating to counting or calculating
What is the purpose of a boolean?
To store a true or false/ determining which part of a script should run.
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
by writing the variable name and assigning it a new value
What is the difference between null and undefined?
undefined = (a variable that has been declared, but no value has been assigned to it yet) null = a variable with no value - it may have had one at some point, but no longer has a value
Why is it a good habit to include “labels” when you log values to the browser console?
So you or your readers can understand what is displayed.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What are objects used for?
grouping together a set of variables and functions. Used to model things.
What are object properties?
variables that are part of an object.
Describe object literal notation.
A way of creating objects by setting variables inside of curly braces.
How do you remove a property from an object?
use the delete keyword followed by the object name . and property name.
What are the two ways to get or update the value of a property?
dot notation or square brackets
What data type is returned by an arithmetic operation?
number type
What is string concatenation?
Combining two or more strings
What purpose(s) does the + plus operator serve in JavaScript?
Adds one value to another or concatenating strings
What data type is returned by comparing two values (, ===, etc)?
Booleans
What does the += “plus-equals” operator do?
add content to an existing variable.
What are arrays used for?
Storing a list of values