Javascript Flashcards
What is the purpose of variables
To store data that you assign to it
How do you declare a variable?
Var
How do you initialize (assign a value to) a variable?
Using the assignment operator of =
What characters are allowed in variable name?
Name must begin with a letter, dollar sign, or underscore. CANNOT begin with a number.
What does it mean to say that variable names are “case sensitive”?
That if a variable has the same name as another variable by one is capitalized, they are not considered the same
What is the purpose of a string?
To add text
What is the purpose of a number?
For task that involve counting or calculating sums
What is the purpose of a boolean?
Helpful when determining what steps are required next depending on what conditions are met
What does the = operator mean in Javascript?
The variable’s values is being assigned to the variable’s name
How do you update the value of a variable?
Once you have declared that variable with the var keyword and assigned it a variable name and value, you only need to call the variable name and assign it a new value
What is the difference between null and undefined?
Undefined means that a value was never assigned to the variable and null is essentially a placeholder for a value created by the developer. In null you can place values in, in undefined you cannot.
What is a good habit to include “labels” when you log values to the browser console?
It helps you from getting confused when logging; it is a short string that describes the variable being logged
Give five examples of JavaScript primitives
String, number, boolean, undefined, and null
What data type is returned by an arithmetic operation?
Numbers
What is string concatenation?
When you combine strings together
What purpose(s) does the + plus operator serve in JavaScript?
To perform arithmetic operations or to concatenate strings
What data type is returned by comparing two values (<, >, ===, etc)
Boolean
What does the += “plus-equals” operator do?
Adds a value to an existing variable and assigns the new value back to the same variable
What are objects used for?
They are used to group together a set of variables and methods
What are object properties?
Variables with a name and value
Describe object literal notation
IT is an array of (key:value) pairs that are are placed inside of curly brackets
How do you remove a property from an object?
by using the delete method nameofObject.property
What are the two ways to get or update the value of a property?
Using period notation or square brackets
What are arrays used for?
To store a list of values