Skip to content

Commit c221209

Browse files
committed
Add ES9 features
1 parent aa02b79 commit c221209

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1386,10 +1386,10 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
13861386
1. You can pass object to a function
13871387
13881388
```js
1389-
function myfunc({ a, ...x }) {
1389+
function myfunc1({ a, ...x }) {
13901390
console.log(a, x); // 1, { b: 2, c: 3, d:4 }
13911391
}
1392-
myfunc({
1392+
myfunc1({
13931393
a: 1,
13941394
b: 2,
13951395
c: 3,

es2018/1.async-iterators.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const arr = ['a', 'b', 'c', 'd'];
2+
const syncIterator = arr[Symbol.iterator]();
3+
4+
console.log(syncIterator.next()); //{value: a, done: false}
5+
console.log(syncIterator.next()); //{value: b, done: false}
6+
console.log(syncIterator.next()); //{value: c, done: false}
7+
console.log(syncIterator.next()); //{value: d, done: false}
8+
console.log(syncIterator.next()); //{value: undefined, done: true}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Rest parameters
2+
3+
function myfunc(p1, p2, ...p3) {
4+
console.log(p1, p2, p3); // 1, 2, [3, 4, 5, 6]
5+
}
6+
myfunc(1, 2, 3, 4, 5, 6);
7+
8+
// spread operator
9+
const myArray = [10, 5, 25, -100, 200, -200];
10+
console.log( Math.max(...myArray) ); // 200
11+
12+
// Rest parameters for objects
13+
function myfunc1({ a, ...x }) {
14+
console.log(a, x); // 1, { b: 2, c: 3, d:4 }
15+
}
16+
myfunc1({
17+
a: 1,
18+
b: 2,
19+
c: 3,
20+
d: 4
21+
});
22+
23+
// spread operator for objects
24+
const myObject = { a: 1, b: 2, c: 3, d:4 };
25+
const myNewObject = { ...myObject, e: 5 }; // { a: 1, b: 2, c: 3, d: 4, e: 5 }

es2018/3.promise-finally.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let isLoading = true;
2+
fetch('http://somesite.com/users')
3+
.then(data => data.json())
4+
.catch(err => console.error(err))
5+
.finally(() => {
6+
isLoading = false;
7+
console.log('Finished loading!!');
8+
})

0 commit comments

Comments
 (0)