JavaScript Flashcards
Up until learning about OOP and ES6 and the event loop
What is the purpose of variables?
To store data for use later on
How do you declare a variable?
Var keyword and variable name
How do you initialize (assign a value to) a variable?
Variable Name = Variable Value
What characters are allowed in variable names?
letters, underscore, dollar sign, numbers (can’t start with this)
What does it mean to say that variable names are “case sensitive”?
There must be consistency in the way names are typed with capitalization
What is the purpose of a string?
Safe enclosure for text data. Add new content to a page.
What is the purpose of a number?
For math and other tasks like size of screen, moving the position of an element on a page, or setting the amount of time an element should take to fade in.
What is the purpose of a boolean?
Generates true or false to determine which part of script should run
What does the = operator mean in JavaScript?
Storing Values
How do you update the value of a variable?
Variable name = new value
What is the difference between null and undefined?
Null: can only exist if it is purposely assigned; acts as a purposeful empty much like a placeholder
Undefined: this is something uses to say nothing or ‘I don’t know’
Why is it a good habit to include “labels” when you log values to the browser console?
Easier for debugging
Give five examples of JavaScript primitives.
String, Number, Boolean, Null, Undefined
What data type is returned by an arithmetic operation?
Numeric
What is string concatenation?
Using the concatenation operator (+)
What purpose(s) does the + plus operator serve in JavaScript?
Concatenation and Math
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
The current value of variable + new value is a result of the new value of the original variable.
What are objects used for?
Grouped data of a set of variables and functions in relation to each other
What are object properties?
Variables that are part of an object
Describe object literal notation.
Curly braces with key value pairs
How do you remove a property from an object?
Delete operator
What are the two ways to get or update the value of a property?
Dot notation and square bracket notation
What are arrays used for?
Making lists of related data as the same type