JavaScript Flashcards
What is the purpose of variables?
They allow us to store values or data to use for functions and other things
How do you declare a variable?
Var variableName = value, need var
How do you initialize (assign a value to) a variable?
Set the variable = to a value with the assignment operator
What characters are allowed in variable names?
Letters, $, _ and numbers, but they can’t start with a number
What does it mean to say that variable names are “case sensitive”?
Varname is a different variable than varname
What is the purpose of a string?
To store and interact with text content
What is the purpose of a number?
To store and interact with numbers
What is the purpose of a boolean?
To store and interact with boolean values. Often used as a switch or to make decisions
What does the = operator mean in JavaScript?
It means ‘assigned the value of’
How do you update the value of a variable?
You reassign it a new value
What is the difference between null and undefined?
Null is an object with no value, undefined has no value or type.
Undefined comes from javascript engine, it helps js tell us if something isn’t there, null has to be defined by the human.
Why is it a good habit to include “labels” when you log values to the browser console?
To know what you are logging
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?
It is when you use the + symbol to add two strings together, called concatenation
What purpose(s) does the + plus operator serve in JavaScript?
It can and numbers and concatenate strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
It adds the value with the variable and assigns that value to the variable
What is an expression
It is a chuck of code in JS.
What are objects used for?
Used to store related data of all different data types (variables and functions)
What are object properties?
They are the individual data types within an object literal
Describe object literal notation.
Object literal notation declares a variable as an object with the assignment operator with the property, value pairs within curly brackets separated by commas.
How do you remove a property from an object?
Use the delete key word and then the property you want to delete in dot notation
What are the two ways to get or update the value of a property?
Dot notation, or bracket notation