JavaScript Flashcards
(101 cards)
What is the purpose of variables?
helps store data to remember
How do you declare a variable?
var declares/makes the variable
How do you initialize (assign a value to) a variable?
you assign it with a = sign.
What characters are allowed in variable names?
letters, $, underscore, and numbers(can be used as long as it’s not the first character)
What does it mean to say that variable names are “case sensitive”?
if you accidentally capitalize a letter it is a WHOLE DIFFERENT VARIABLE.
What is the purpose of a string?
it’s a way to hold a sequence of variables
What is the purpose of a number?
to do math
What is the purpose of a boolean?
a true or false statement
What does the = operator mean in JavaScript?
an assignment
How do you update the value of a variable?
no keyword is necessary (something = ‘something’)
What is the difference between null and undefined?
null is a value that can only be assigned. undefined can come from many different things.
Why is it a good habit to include “labels” when you log values to the browser console?
if you console.log without a label you don’t know what it really is.
Give five examples of JavaScript primitives.
string, number, undefined, null, and boolean.
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
adding strings together to make a bigger string
What purpose(s) does the + plus operator serve in Javascript?
addition or concateanation.
What data type is returned by comparing the two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the variable
What are objects used for?
They group together a set of variables and functions.
What are object properties?
variables that are apart of an object.
Describe object literal notation.
{
something: value,
something2: value2,
}
How do you remove a property from an object?
You use the keyword delete and then use dot notation to identify the property or method you want to get rid of.
What are the two ways to get or update the value of a property?
var varName = object.property/method name
OR
object.propertyname = “property value”
What are arrays used for?
good for rendering lists of data that are important or not important.