Javascript Flashcards
(161 cards)
What is the purpose of a number?
To assign numerical value
What is the purpose of a boolean?
To determine if something is true or false
What does the = operator mean in JavaScript?
It says that you are going to assign a value to a variable
How do you update the value of a variable?
By recalling the variable by the name and using the assignment operator to assign it a new value
What is the difference between null and undefined?
null is an assigned value. It means nothing.(intentional empty) undefined means a variable has been declared but not defined yet
Why is it a good habit to include “labels” when you log values to the browser console?
to help you debug, but if you do not include “labels”, it can be very confusing instead of helpful
Give five examples of JavaScript primitives.
string, number, boolean, undefined, and null.
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Taking two strains and putting them together
What purpose(s) does the + plus operator serve in JavaScript?
To add values and concatenate
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left
What are arrays used for?
To store a list of values
Describe array literal notation.
The values are assigned to the array inside a pair of square brackets, and each value is separated by a comma.
How are arrays different from “plain” objects?
It holds a list of related values in order, white object holds list of values out of order
What number represents the first index of an array?
0
What is the length property of an array?
It holds the number of items in the array
How do you calculate the last index of an array?
Subtracting 1 from the length of an array
What are objects used for?
To group together a set of variables and functions to create a model
What are object properties?
Variables that are part of an object.
Describe object literal notation.
Object is contained by curly braces,
You separate each key from its value by using a colon, separate each property and method with a comma.
How do you remove a property from an object?
Use keyword delete operator followed by dot notation
What are the two ways to get or update the value of a property?
Using dot notation or brackets notation
What is a function in JavaScript?
Functions allow you to package up code for use later in your program.