JavaScript Flashcards
What is the purpose of variables?
To help store data for the computer to remember
How do you declare a variable?
Creating the variable (keyword) and giving it a name
How do you initialize (assign a value to) a variable?
You use the = operator
What characters are allowed in variable names?
Letters, Dollar Signs, Numbers, Underscore
Can’t start with number, use periods, or dashes
What does it mean to say that variable names are “case sensitive”?
They must match or else they are two different variables
What is the purpose of a string?
A way to hold a sequence of characters
Used to represent characters
What is the purpose of a number?
To store number and used for math
What is the purpose of a boolean?
To let the user know whether something is true or false
Helps the user make a choice based on the output
What does the = operator mean in JavaScript?
It is an assignment operator
How do you update the value of a variable?
You write the variable and use the assignment operator with a new value
What is the difference between null and undefined?
Null means intentional absence of a value (Like a placeholder for you to put in value later) while undefined means no value was assigned to a variable
Why is it a good habit to include “labels” when you log values to the browser console?
Makes it much easier for you see which variable is being logged and in what order
Give five examples of JavaScript primitives.
String, Number, Null, Undefined, Boolean
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
The process of joining a value with another string and resulting in a new string
What purpose(s) does the + plus operator serve in JavaScript?
To add two values together or concatenate string together
What data type is returned by comparing two values (<, >, ===, etc)?
A Boolean
What does the += “plus-equals” operator do?
Adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
They group together a set of variables and functions to create a model of something you would see in the real world
Ex. An organized bubble where you can get bits of information from of the object that are related to one another
What are object properties?
The key and values within the object (The data within the object)
Describe object literal notation.
The object properties (Key and values)
How do you remove a property from an object?
Using the delete operator followed by object name and key
What are the two ways to get or update the value of a property?
Dot notation and bracket notation
What are arrays used for?
For creating a list of values that are related to one another with order may or may not mattering
Describe array literal notation.
A variable and name followed by = with square brackets with content separated by comma’s
How are arrays different from “plain” objects?
Arrays have a length property, arrays call a method to add data while objects assign it, arrays have an order while objects don’t
What number represents the first index of an array?
[0]
What is the length property of an array?
True count of items within the array
How do you calculate the last index of an array?
.length - 1