JavaScript Flashcards
What is the purpose of variables?
to store data
How do you declare a variable?
use keyword “var”
How do you initialize (assign a value to) a variable?
var variable = something
What characters are allowed in variable names?
letter, digits, underscore, dollar signs
What does it mean to say that variable names are “case sensitive”?
they must be recalled exactly as they were saved
What is the purpose of a string?
store and manipulate text
What is the purpose of a number?
store and manipulate data
What is the purpose of a boolean?
to register something as true or false
What does the = operator mean in JavaScript?
it is assigning a value to a variable name
What is the difference between null and undefined?
null is intentionally given a non-existing value, undefined unintentionally lacks a value
Why is it a good habit to include “labels” when you log values to the browser console?
so that you have a better idea of what issues may have occurred when debugging
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
to update a variable
use variable followed by value… don’t need to use ‘var’ again
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
the combining of two or more strings
What purpose(s) does the + plus operator serve in JavaScript?
it adds a value to another variable/value
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds a value to a variable and re-assigns the variable
What are objects used for?
group together set of variables and functions
What are object properties?
a variable within an object
Describe object literal notation.
a saved variable followed by curly brace with key-value properties and methods (functions)
How do you remove a property from an object?
delete then object.property
What are the two ways to get or update the value of a property?
either dot or bracket notation
What are arrays used for?
storing a list of values