JavaScript Flashcards
(26 cards)
Name all the truthy values in javascript.
- {}
- []
- 42
- “false”
- new Date(),
- -42
- 3.14
- -3.14
- Infinity
- -Infinity
- all objects
Name all the falsy values in javascript.
- false (boolean)
- 0
- -0
- 0n
- ””
- null
- undefined
- NaN
in a method, what does this refer to?
the owner object
in strict mode, what does this refer to?
undefined
What’s an expression in Javascript?
any line of code that resolves to a value.
(can still resolve to null or undefined)
What’s a statement in Javascript?
performs an action. Doesn’t necessarily return a value.
What is Object restructuring ?
allows you to extract properties from an object into individual variables
What does a Spread operator do?
allows an iterable such as an array or string to be expanded in places where zero or more arguments or elements are expected.
Describe strict mode.
Helps eliminate some silent errors by changing them into throw errors
In strict mode, this is undefined in functions that are not methods or constructors.
What is the global object?
the default container that holds functions, variables and built in objects ( Math, Date, console etc.)
What is the owner object?
the object the method belongs to.
Are functions objects?
Yes.
In an array what does push() do?
add new elements(multiple) to the end of array + returns it.
In an array what does pop() do?
Removes the last element (one at a time) from an array, and returns it.
In an array what does shift() do?
Removes the first element from an array, and returns that. (one at a time)
In an array what does unshift() do?
Adds new elements to the beginning of an array, and returns
the new length.
In an array what does slice() do?
Returns a shallow copy of a portion of an array.
In an array what does splice() do?
Changes the contents of an array by removing or replacing
existing elements and/or adding new elements.
In an array what does concat() do?
Used to merge two or more arrays, and returns a new array.
What is an object?
A JavaScript object is a collection of properties where each property is an association between a key and a value.
What is an object literal?
a list of zero or more pairs of property names and
associated values of an object, enclosed in curly braces ({}).
What’s the first line of an object constructor?
let object_name = new Object();
What does Object.keys()
do?
returns an array of all the object’s keys.
What does Object.entries()
do?
returns an array of all the object’s key/value pairs
aka all keys and all values.