Javascript Flashcards
What is the purpose of variables?
to store data/information
How do you declare a variable?
with a variable’s keyword and a variable name (ex. var fullName)
How do you initialize (assign a value to) a variable?
by giving the variable a value using an assignment operator (usually =)
What characters are allowed in variable names?
Variable names cannot contain space
names must begin with a letter, underscore, or dollar sign
variable names can only contain letters, numbers, underscores, or dollar signs
variable names are case sensitive
What does it mean to say that variable names are case sensitive?
variables can store different values if using different casing even with the same word(s).
What is the purpose of a string?
store text data
What is the purpose of a number?
store numeric data
What is the purpose of a boolean?
act as an on/off switch to determine whether a script should run
aka makes decisions
What does the “=” operator mean in Javascript?
assignment operator
assigns a value to a variable
How do you update the value of a variable?
variableName = new value
you don’t need the variable keyword.
What is the difference between “null” and “undefined”?
undefined is the computer saying “nothing”
null is the programmer/human saying “nothing”
vacant lot versus parking lot
Why is it a good habit to include “labels” when you log values to the browser console?
provides clarity to other programmers as to where the values are coming from
good reminder for yourself as well
Give 7 examples of javascript primitives:
strings numbers booleans null undefined bigint symbols
What data type is returned by an arithmetic operation?
numeric
What is string concatenation?
combining two or more strings together to make a new longer string
strings are immutable
What purpose(s) does the “+” operator serve in Javascript?
concatenate strings
add numbers together
What data type is returned by comparing two values (, ===, etc)?
boolean
what does the += operator do?
variable = variable + value
What are objects used for?
Helps us to store and collect data in pairs or groupings.
What are object properties?
key:value pairs
Describe object literal notation:
{}
How do you remove a property from an object?
use the delete keyword
delete object.property;
What are the two ways to get or update the value of a property of an object?
Dot notation object.property = “new value”;
Square bracket notation object[“property”] = “new value”
What are arrays used for?
storing list data