ES7 and ES8 Flashcards

1
Q

Convert let a = Math.pow(2,5); to es7

A

let a = 2**5;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which method within ES7 checks if an element exists in an array?

a. contains()
b. includes()
c. has()

A

b. includes()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following method within the ES7 Object prototype can return both keys and values for an object?

a. entries()
b. values()
c. keys()

A

a. entries(). This function will return an array of two-length arrays that represent the keys and values of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which keyword tells an async function to wait for a resolved value before continuing to execute code?

a. async
b. await

A

This keyword will block an async function from continuing until the ‘awaited’ value returns a valid response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why do we create modules in modern JavaScript Projects?

A

To keep each file/module focused and manageable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Classes are a feature which basically replace constructor ______ and _____.

A

functions and prototypes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two new variable names for es7?

A

const and let

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The spread and rest operators use the same syntax:

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Is this using a spread or a rest operator?

const oldArray = [1, 2, 3];
const newArray = [...oldArray, 4, 5]; // This now is [1, 2, 3, 4, 5];
A

spread operator: It pulls elements out of an array or object

The spread operator is extremely useful for cloning arrays and objects. Since both are reference types (and not primitives), copying them safely (i.e. preventing future mutation of the copied original) can be tricky. With the spread operator you have an easy way of creating a (shallow!) clone of the object or array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Is this using a spread or a rest operator?

const array = [1, 2, 3];
const [a, b] = array;
console.log(a); // prints 1
console.log(b); // prints 2
console.log(array); // prints [1, 2, 3]
A

Rest(destructing operator)

It allows you to easily access the values of arrays or objects and assign them to variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly