JavaScript Flashcards
(157 cards)
What is the purpose of variables?
to hold data (numbers, strings, booleans)
How do you declare a variable?
by creating a variable name
How do you initialize (assign a value to) a variable?
adding an equal sign next the variable name and then giving it a value/data
What characters are allowed in variable names?
letters, $, numbers but we shouldn’t use numbers
What does it mean to say that variable names are “case sensitive”?
it means that the capitalization needs to be the same in order to call that variable (ex. var myName and var MyName is two different variables)
What is the purpose of a string?
it holds the data type of letters and other characters
What is the purpose of a number?
it holds the data type of numbers (integers, decimals, etc)
What is the purpose of a boolean?
it holds the data type of one of two values, true or false
What does the = operator mean in JavaScript?
a value is being assigned to a variable
How do you update the value of a variable?
by assigning it to a new value
What is the difference between null and undefined?
null is subject to change, there is nothing but it could change into something. while undefined is literally nothing
Why is it a good habit to include “labels” when you log values to the browser console?
so that you won’t get confused to what is being logged
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
when two or more strings are added together
What purpose(s) does the + plus operator serve in JavaScript?
used to add one value to another
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
it adds and re-assigns a new value to a variable
What are objects used for?
to hold a set of variables that all link to one thing/object
What are object properties?
it tells us about the object, stores info ab the object (ex. name:, age:,)
Describe object literal notation.
an array of keys and values
How do you remove a property from an object?
using the delete operator
What are the two ways to get or update the value of a property?
using a dot notation or bracket notation (ex. example.name, example[‘name’])
What are arrays used for?
to store multiple values