JS Flashcards
(108 cards)
What is the purpose of variables?
Variables are used to store information that will be used later
How do you declare a variable?
We declare a variable by using the var keyword followed by the variable
name, then assignment operator followed by a value
How do you initialize (assign a value to) a variable?
We use variable name, followed by the assignment
operator (=) followed by a variable value
What characters are allowed in variable names?
letters, numbers, underscore, and dollar signs, but
variables can not begin with a number
What does it mean to say that variable names are ”case sensitive”?
It means uppercase and lowercase
letters has an affect on the word name. As an example, ”A” is different that ”a
What is the purpose of a string?
Used for tasks involving text content or tasks involving words or
phrases
What is the purpose of a number?
Used for tasks involving counting, adding, or mathematical operations,or anything that involves numbers
What is the purpose of a boolean?
Used for true/false tasks or used for decision making
What does the = operator mean in JavaScript?
= is an assignment operator. It sets a variable to
equal something or update a variable’s value
How do you update the value of a variable?
We will use the assignment operator for the variable
What is the difference between null and undefined?
null means the value is nonexistent where undefined
means the variable has not been defined or the variable has just been declared
Why is it a good habit to include ”labels” when you log values to the browser console?
So we can know what the outputs are referring to
Give five examples of JavaScript primitives
- string
- number
- boolean
- undefined
- null
- symbol
- bigint
2
What data type is returned by an arithmetic operation?
numbers
What is string concatenation?
It is combining two strings into one string
What purpose(s) does the + plus operator serve in JavaScript?
this is used for string concatenation
and addition
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += ”plus-equals” operator do?
this will add the number and then set the variable
equal to the result
What are objects used for?
Objects are a group of variables and functions used to create a model of
something from the real world
What are object properties?
Object properties are variables that are apart of an object
Describe object literal notation
Object literal notation is used to create an object. We start with a
var keyword followed by a variable name with the assignment operator and curly braces. Inside the
curly braces, we have a key and their value separated by a colon. Each key is separated by a comma
How do you remove a property from an object?
We would use the delete operator followed by the
object name, period, and the property we want to remove
What are the two ways to get or update the value of a property?
to access the value of a property, we would use object, period, followed by the property name (object.newValue).
To update the value of an object property, we would used, object, open bracket, property name, close
bracket, assignment operator, and the new property value. (object[’property’] = newValue)
What are arrays used for?
Arrays are used for storing data in an organized and predictable manner.
Each value is enumerated. Store a list of data in a set order