{"action":"created","issue":{"url":"https://api.github.com/repos/HanSummer/awesome-web/issues/59","repository_url":"https://api.github.com/repos/HanSummer/awesome-web","labels_url":"https://api.github.com/repos/HanSummer/awesome-web/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/HanSummer/awesome-web/issues/59/comments","events_url":"https://api.github.com/repos/HanSummer/awesome-web/issues/59/events","html_url":"https://github.com/HanSummer/awesome-web/issues/59","id":300080745,"number":59,"title":"es6 扩展运算符 三个点（...）","user":{"login":"HanSummer","id":27877634,"avatar_url":"https://avatars0.githubusercontent.com/u/27877634?v=4","gravatar_id":"","url":"https://api.github.com/users/HanSummer","html_url":"https://github.com/HanSummer","followers_url":"https://api.github.com/users/HanSummer/followers","following_url":"https://api.github.com/users/HanSummer/following{/other_user}","gists_url":"https://api.github.com/users/HanSummer/gists{/gist_id}","starred_url":"https://api.github.com/users/HanSummer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanSummer/subscriptions","organizations_url":"https://api.github.com/users/HanSummer/orgs","repos_url":"https://api.github.com/users/HanSummer/repos","events_url":"https://api.github.com/users/HanSummer/events{/privacy}","received_events_url":"https://api.github.com/users/HanSummer/received_events","type":"User","site_admin":false},"labels":[{"id":602561157,"url":"https://api.github.com/repos/HanSummer/awesome-web/labels/Native%20JS","name":"Native JS","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-02-26T01:07:31Z","updated_at":"2018-02-26T01:23:15Z","closed_at":null,"author_association":"OWNER","body":"## 参考\r\n[http://blog.csdn.net/qq_30100043/article/details/53391308](url)\r\n\r\n## 含义\r\n扩展运算符（ spread ）是三个点（...）。它好比 rest 参数的逆运算，将一个数组转为用逗号分隔的参数序列。\r\n\r\n## 注意\r\n扩展运算符内部调用的是数据结构的 Iterator 接口，因此只要具有 Iterator 接口的对象，都可以使用扩展运算符"},"comment":{"url":"https://api.github.com/repos/HanSummer/awesome-web/issues/comments/368364936","html_url":"https://github.com/HanSummer/awesome-web/issues/59#issuecomment-368364936","issue_url":"https://api.github.com/repos/HanSummer/awesome-web/issues/59","id":368364936,"user":{"login":"HanSummer","id":27877634,"avatar_url":"https://avatars0.githubusercontent.com/u/27877634?v=4","gravatar_id":"","url":"https://api.github.com/users/HanSummer","html_url":"https://github.com/HanSummer","followers_url":"https://api.github.com/users/HanSummer/followers","following_url":"https://api.github.com/users/HanSummer/following{/other_user}","gists_url":"https://api.github.com/users/HanSummer/gists{/gist_id}","starred_url":"https://api.github.com/users/HanSummer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanSummer/subscriptions","organizations_url":"https://api.github.com/users/HanSummer/orgs","repos_url":"https://api.github.com/users/HanSummer/repos","events_url":"https://api.github.com/users/HanSummer/events{/privacy}","received_events_url":"https://api.github.com/users/HanSummer/received_events","type":"User","site_admin":false},"created_at":"2018-02-26T01:23:15Z","updated_at":"2018-02-26T01:23:15Z","author_association":"OWNER","body":"## Map 和 Set 结构， Generator 函数\r\n扩展运算符内部调用的是数据结构的 Iterator 接口，因此只要具有 Iterator 接口的对象，都可以使用扩展运算符，比如 Map 结构。\r\n\r\n```\r\nlet map = new Map([  \r\n[1, 'one'],  \r\n[2, 'two'],  \r\n[3, 'three'],  \r\n]);  \r\nlet arr = [...map.keys()]; // [1, 2, 3]  \r\n```\r\nGenerator 函数运行后，返回一个遍历器对象，因此也可以使用扩展运算符。\r\n```\r\nvar go = function*(){  \r\nyield 1;  \r\nyield 2;  \r\nyield 3;  \r\n};  \r\n[...go()] // [1, 2, 3]  \r\n```\r\n上面代码中，变量go是一个 Generator 函数，执行后返回的是一个遍历器对象，对这个遍历器对象执行扩展运算符，就会将内部遍历得到的值，转为一个数组。\r\n\r\n如果对没有iterator接口的对象，使用扩展运算符，将会报错。\r\n\r\n```\r\nvar obj = {a: 1, b: 2};  \r\nlet arr = [...obj]; // TypeError: Cannot spread non-iterable object  \r\n```"}}
{"actor":{"display_login":"HanSummer"}}