JavaScript Flashcards
What is the purpose of variables?
To store data so we can access them in the future and multiple times
How do you declare a variable?
Using the variable keyword ‘var’
How do you initialize (assign a value to) a variable?
Using the assignment operator “=” after declaring the variable
What characters are allowed in variable names?
Letters, numbers (but cannot start with a number), dollar signs and underscore
What does it mean to say that variable names are “case sensitive”?
The same word with a capital letter would be different variable names
What is the purpose of a string?
To save text content or series or characters
What is the purpose of a number?
To save for counting and calculating sums
What is the purpose of a boolean?
To save for when there are only two values “True & False” or “Yes & No”. Used for decisions
What does the = operator mean in JavaScript?
It is an assignment operator. It assigns values to variables
How do you update the value of a variable?
To reassign it by using the declared value
What is the difference between null and undefined?
Null is an intentional absence of a value (var hello = null) whereas undefined is a variable that hasn’t been initialized yet (just declared ‘var hello;’)
Why is it a good habit to include “labels” when you log values to the browser console?
So you can easily see what is being logged
Give five examples of JavaScript primitives. String, boolean, number, null, undefined
What data type is returned by an arithmetic operation?
An expression
What is string concatenation?
Joining two or more string values to create a new string
What purpose(s) does the + plus operator serve in JavaScript?
To add number values or to concatenate string values
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Adds or concatenates the value of the right to the left of the operator and then assigns the result of the expression to the to the variable on the left
What are objects used for?
To group together a set of variables and functions around one subject
What are object properties?
A variable within an object
Describe object literal notation.
Define a new variable and assign it to an object literal using curly braces. Using property and values
How do you remove a property from an object?
Delete operator followed by dot notation object.property
What are the two ways to get or update the value of a property?
Using the dot notation or the bracket notation
What are object methods?
A function within an object
What are arrays used for?
Arrays store a list of values that are related to each other