Skip to content

Commit

Permalink
update notes
Browse files Browse the repository at this point in the history
  • Loading branch information
sean_chou committed Sep 1, 2018
1 parent cc3e1cf commit 9432527
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 38 additions & 1 deletion js/javascript-es6-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ES6
# ES6 new feature

## Symbol

Expand Down Expand Up @@ -28,6 +28,43 @@ reference:
https://zhuanlan.zhihu.com/p/22652486
http://es6.ruanyifeng.com/#docs/symbol

## Set and Map

### Set

類似於 array,但是內容不能重複

```js
const set = new Set([4, 5, 6, 7, 2, 5, 6, 2, 2, 2]);

for (let s of set) {
console.log(s);
}

// 只會印出 4, 5, 6, 7, 2
```

#### Set function

* size(): 回傳 Set 大小
* add(value): 加入新值,回傳 Set 本身
* delete(value): 刪除一個值,回傳成功與否的 boolean
* has(value): 回傳有無特定值 boolean
* clear(): 清除所有元素,no return
* keys: 回傳 keys 的 iterator
* values: 回傳 values 的 iterator
> Set 只有值,所以 keys and values 兩者會一樣
* entries: 回傳 keys+values 的 iterator
> Set 只有值,所以兩者會一樣 => [key, value]
#### WeakSet

### Map

讓 JavaScript object 中的 key 可以使用 string 以外的型態。




## Generator

Expand Down
2 changes: 2 additions & 0 deletions typescript/iterator.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Iterator

TypeScript 2.3 adds full support for generators and the Iterator

https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html

Expand Down

0 comments on commit 9432527

Please sign in to comment.