{"action":"created","comment":{"url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/comments/89195422","pull_request_review_id":9743083,"id":89195422,"diff_hunk":"@@ -0,0 +1,961 @@\n+# 9.0 - ES5 vs ES6\n+\n+# Purpose\n+\n+- JavaScript: The commonly used name for implementations of the ECMAScript standard. This term isn't tied to a particular version of the ECMAScript standard, and may be used to refer to implementations that implement all or part of any particular ECMASCript edition.\n+\n+- ECMAScript 5 (ES5): The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers\n+\n+- ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015): The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers. To see the state of implementation by different browsers and tools, check out these compatibility tables:\n+\n+http://kangax.github.io/compat-table/es6/\n+\n+#### Below is a list of ES6 features along with what that feature looks like when written with the equivalent ES5 code.\n+\n+**Table of contents:**\n+\n+1. [Arrow Functions](#arrow-functions)\n+1. [Block Scoping Functions](#block-scoping-functions)\n+1. [Template Literals](#template-literals)\n+1. [Computed Property Names](#computed-property-names)\n+1. [Destructuring Assignment](#destructuring-assignment)\n+1. [Default Parameters](#default-parameters)\n+1. [Iterators and For-Of](#iterators-and-for-of)\n+1. [Classes](#classes)\n+1. [Modules](#modules)\n+1. [Numeric Literals](#numeric-literals)\n+1. [Property Method Assignment](#property-method-assignment)\n+1. [Object Initializer Shorthand](#object-initializer-shorthand)\n+1. [Rest Parameters](#rest-parameters)\n+1. [Spread Operator](#spread-operator)\n+1. [Proxying a function object](#proxying-a-function-object)\n+1. [Array-like object to array](#array-like-object-to-array)\n+1. [About](#about)\n+1. [License](#license)\n+\n+## Arrow Functions\n+\n+An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value. Arrow functions are always anonymous.\n+\n+\n+ES6:\n+\n+```js\n+[1, 2, 3].map(n => n * 2);\n+// -> [ 2, 4, 6 ]\n+```\n+\n+ES5 equivalent:\n+\n+```js\n+[1, 2, 3].map(function(n) { return n * 2; }, this);\n+// -> [ 2, 4, 6 ]\n+```\n+\n+ES6:\n+\n+```js\n+var evens = [2, 4, 6, 8, 10];\n+\n+// Expression bodies\n+var odds = evens.map(v => v + 1);\n+var nums = evens.map((v, i) => v + i);\n+\n+console.log(odds);\n+// -> [3, 5, 7, 9, 11]\n+\n+console.log(nums);\n+// -> [2, 5, 8, 11, 14]\n+\n+// Statement bodies\n+var fives = [];\n+nums = [1, 2, 5, 15, 25, 32];\n+nums.forEach(v => {\n+  if (v % 5 === 0)\n+    fives.push(v);\n+});\n+\n+console.log(fives);\n+// -> [5, 15, 25]\n+\n+// Lexical this\n+var bob = {\n+  _name: 'Bob',\n+  _friends: [],\n+  printFriends() {\n+    this._friends.forEach(f =>\n+      console.log(this._name + ' knows ' + f));\n+  }\n+}\n+```\n+\n+ES5:\n+\n+```js\n+'use strict';\n+\n+var evens = [2, 4, 6, 8, 10];\n+\n+// Expression bodies\n+var odds = evens.map(function (v) {\n+  return v + 1;\n+}, this);\n+var nums = evens.map(function (v, i) {\n+  return v + i;\n+}, this);\n+\n+console.log(odds);\n+// -> [3, 5, 7, 9, 11]\n+\n+console.log(nums);\n+// -> [2, 5, 8, 11, 14]\n+\n+var fives = [];\n+nums = [1, 2, 5, 15, 25, 32];\n+\n+// Statement bodies\n+nums.forEach(function (v) {\n+  if (v % 5 === 0) {\n+    fives.push(v);\n+  }\n+}, this);\n+\n+console.log(fives);\n+// -> [5, 15, 25]\n+\n+// Lexical this\n+var bob = {\n+  _name: 'Bob',\n+  _friends: [],\n+  printFriends: function printFriends() {\n+    this._friends.forEach(function (f) {\n+      return console.log(this._name + ' knows ' + f);\n+    }, this);\n+  }\n+};\n+```\n+\n+## Block Scoping Functions\n+\n+Block scoped bindings provide scopes other than the function and top level scope. This ensures your variables don't leak out of the scope they're defined:\n+\n+ES6:\n+\n+```js\n+// let declares a block scope local variable,\n+// optionally initializing it to a value in ES6\n+\n+'use strict';\n+\n+var a = 5;\n+var b = 10;\n+\n+if (a === 5) {\n+  let a = 4; // The scope is inside the if-block\n+  var b = 1; // The scope is inside the function\n+\n+  console.log(a);  // 4\n+  console.log(b);  // 1\n+}\n+\n+console.log(a); // 5\n+console.log(b); // 1\n+```\n+\n+ES5:\n+\n+```js\n+'use strict';\n+\n+var a = 5;\n+var b = 10;\n+\n+if (a === 5) {\n+  // technically is more like the following\n+  (function () {\n+    var a = 4;\n+    b = 1;\n+\n+    console.log(a); // 4\n+    console.log(b); // 1\n+  })();\n+}\n+\n+console.log(a); // 5\n+console.log(b); // 1\n+```\n+\n+\n+ES6:\n+\n+```js\n+// const creates a read-only named constant in ES6.\n+'use strict';\n+// define favorite as a constant and give it the value 7\n+const favorite = 7;\n+// Attempt to overwrite the constant\n+try {\n+  favorite = 15;\n+} catch (err) {\n+  console.log('my favorite number is still: ' + favorite);\n+  // will still print 7\n+}\n+```","path":"language-examples/remedial-js/9.0-ES5-vs-ES6/README.md","position":203,"original_position":203,"commit_id":"5d212c946515b44e667c4de2aecd4f626e4c9b97","original_commit_id":"5d212c946515b44e667c4de2aecd4f626e4c9b97","user":{"login":"turbobeast","id":1766472,"avatar_url":"https://avatars.githubusercontent.com/u/1766472?v=3","gravatar_id":"","url":"https://api.github.com/users/turbobeast","html_url":"https://github.com/turbobeast","followers_url":"https://api.github.com/users/turbobeast/followers","following_url":"https://api.github.com/users/turbobeast/following{/other_user}","gists_url":"https://api.github.com/users/turbobeast/gists{/gist_id}","starred_url":"https://api.github.com/users/turbobeast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turbobeast/subscriptions","organizations_url":"https://api.github.com/users/turbobeast/orgs","repos_url":"https://api.github.com/users/turbobeast/repos","events_url":"https://api.github.com/users/turbobeast/events{/privacy}","received_events_url":"https://api.github.com/users/turbobeast/received_events","type":"User","site_admin":false},"body":"I think it might be worth mentioning that only attempting to bind a new value to a variable declared with `const` throws. it does not protect against mutation. \r\n```javascript\r\nconst myObj = { name: 'constobj' }\r\nmyObj.name = 'mutableObj'\r\nmyObj.name // 'mutableObj'\r\n\r\nmyObj = { name: 'wholenewObj' } // error\r\n```","created_at":"2016-11-22T19:45:11Z","updated_at":"2016-11-22T19:45:11Z","html_url":"https://github.com/rangle/angular-training-examples/pull/24#discussion_r89195422","pull_request_url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/comments/89195422"},"html":{"href":"https://github.com/rangle/angular-training-examples/pull/24#discussion_r89195422"},"pull_request":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24","id":93645427,"html_url":"https://github.com/rangle/angular-training-examples/pull/24","diff_url":"https://github.com/rangle/angular-training-examples/pull/24.diff","patch_url":"https://github.com/rangle/angular-training-examples/pull/24.patch","issue_url":"https://api.github.com/repos/rangle/angular-training-examples/issues/24","number":24,"state":"open","locked":false,"title":"Es6 vs es5","user":{"login":"sinelanguage","id":1165172,"avatar_url":"https://avatars.githubusercontent.com/u/1165172?v=3","gravatar_id":"","url":"https://api.github.com/users/sinelanguage","html_url":"https://github.com/sinelanguage","followers_url":"https://api.github.com/users/sinelanguage/followers","following_url":"https://api.github.com/users/sinelanguage/following{/other_user}","gists_url":"https://api.github.com/users/sinelanguage/gists{/gist_id}","starred_url":"https://api.github.com/users/sinelanguage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinelanguage/subscriptions","organizations_url":"https://api.github.com/users/sinelanguage/orgs","repos_url":"https://api.github.com/users/sinelanguage/repos","events_url":"https://api.github.com/users/sinelanguage/events{/privacy}","received_events_url":"https://api.github.com/users/sinelanguage/received_events","type":"User","site_admin":false},"body":"connect rangle/angular-training-slides#42","created_at":"2016-11-14T20:50:57Z","updated_at":"2016-11-22T19:45:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f017af53e98609ed4d64f6007c740cc3c92be677","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24/commits","review_comments_url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24/comments","review_comment_url":"https://api.github.com/repos/rangle/angular-training-examples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rangle/angular-training-examples/issues/24/comments","statuses_url":"https://api.github.com/repos/rangle/angular-training-examples/statuses/5d212c946515b44e667c4de2aecd4f626e4c9b97","head":{"label":"sinelanguage:es6-vs-es5","ref":"es6-vs-es5","sha":"5d212c946515b44e667c4de2aecd4f626e4c9b97","user":{"login":"sinelanguage","id":1165172,"avatar_url":"https://avatars.githubusercontent.com/u/1165172?v=3","gravatar_id":"","url":"https://api.github.com/users/sinelanguage","html_url":"https://github.com/sinelanguage","followers_url":"https://api.github.com/users/sinelanguage/followers","following_url":"https://api.github.com/users/sinelanguage/following{/other_user}","gists_url":"https://api.github.com/users/sinelanguage/gists{/gist_id}","starred_url":"https://api.github.com/users/sinelanguage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinelanguage/subscriptions","organizations_url":"https://api.github.com/users/sinelanguage/orgs","repos_url":"https://api.github.com/users/sinelanguage/repos","events_url":"https://api.github.com/users/sinelanguage/events{/privacy}","received_events_url":"https://api.github.com/users/sinelanguage/received_events","type":"User","site_admin":false},"repo":{"id":73723131,"name":"angular-training-examples","full_name":"sinelanguage/angular-training-examples","owner":{"login":"sinelanguage","id":1165172,"avatar_url":"https://avatars.githubusercontent.com/u/1165172?v=3","gravatar_id":"","url":"https://api.github.com/users/sinelanguage","html_url":"https://github.com/sinelanguage","followers_url":"https://api.github.com/users/sinelanguage/followers","following_url":"https://api.github.com/users/sinelanguage/following{/other_user}","gists_url":"https://api.github.com/users/sinelanguage/gists{/gist_id}","starred_url":"https://api.github.com/users/sinelanguage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinelanguage/subscriptions","organizations_url":"https://api.github.com/users/sinelanguage/orgs","repos_url":"https://api.github.com/users/sinelanguage/repos","events_url":"https://api.github.com/users/sinelanguage/events{/privacy}","received_events_url":"https://api.github.com/users/sinelanguage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sinelanguage/angular-training-examples","description":"Blog application for Angular 2 training","fork":true,"url":"https://api.github.com/repos/sinelanguage/angular-training-examples","forks_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/forks","keys_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/teams","hooks_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/hooks","issue_events_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/issues/events{/number}","events_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/events","assignees_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/assignees{/user}","branches_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/branches{/branch}","tags_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/tags","blobs_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/git/refs{/sha}","trees_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/statuses/{sha}","languages_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/languages","stargazers_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/stargazers","contributors_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/contributors","subscribers_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/subscribers","subscription_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/subscription","commits_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/commits{/sha}","git_commits_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/git/commits{/sha}","comments_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/comments{/number}","issue_comment_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/issues/comments{/number}","contents_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/contents/{+path}","compare_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/merges","archive_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/downloads","issues_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/issues{/number}","pulls_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/pulls{/number}","milestones_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/milestones{/number}","notifications_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/labels{/name}","releases_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/releases{/id}","deployments_url":"https://api.github.com/repos/sinelanguage/angular-training-examples/deployments","created_at":"2016-11-14T16:11:54Z","updated_at":"2016-11-14T16:11:56Z","pushed_at":"2016-11-22T19:37:28Z","git_url":"git://github.com/sinelanguage/angular-training-examples.git","ssh_url":"git@github.com:sinelanguage/angular-training-examples.git","clone_url":"https://github.com/sinelanguage/angular-training-examples.git","svn_url":"https://github.com/sinelanguage/angular-training-examples","homepage":null,"size":137,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rangle:master","ref":"master","sha":"cbdde2a8bf3e4551b88bd6e95c25e2ccd368f32d","user":{"login":"rangle","id":4304982,"avatar_url":"https://avatars.githubusercontent.com/u/4304982?v=3","gravatar_id":"","url":"https://api.github.com/users/rangle","html_url":"https://github.com/rangle","followers_url":"https://api.github.com/users/rangle/followers","following_url":"https://api.github.com/users/rangle/following{/other_user}","gists_url":"https://api.github.com/users/rangle/gists{/gist_id}","starred_url":"https://api.github.com/users/rangle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rangle/subscriptions","organizations_url":"https://api.github.com/users/rangle/orgs","repos_url":"https://api.github.com/users/rangle/repos","events_url":"https://api.github.com/users/rangle/events{/privacy}","received_events_url":"https://api.github.com/users/rangle/received_events","type":"Organization","site_admin":false},"repo":{"id":65301220,"name":"angular-training-examples","full_name":"rangle/angular-training-examples","owner":{"login":"rangle","id":4304982,"avatar_url":"https://avatars.githubusercontent.com/u/4304982?v=3","gravatar_id":"","url":"https://api.github.com/users/rangle","html_url":"https://github.com/rangle","followers_url":"https://api.github.com/users/rangle/followers","following_url":"https://api.github.com/users/rangle/following{/other_user}","gists_url":"https://api.github.com/users/rangle/gists{/gist_id}","starred_url":"https://api.github.com/users/rangle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rangle/subscriptions","organizations_url":"https://api.github.com/users/rangle/orgs","repos_url":"https://api.github.com/users/rangle/repos","events_url":"https://api.github.com/users/rangle/events{/privacy}","received_events_url":"https://api.github.com/users/rangle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rangle/angular-training-examples","description":"Blog application for Angular 2 training","fork":false,"url":"https://api.github.com/repos/rangle/angular-training-examples","forks_url":"https://api.github.com/repos/rangle/angular-training-examples/forks","keys_url":"https://api.github.com/repos/rangle/angular-training-examples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rangle/angular-training-examples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rangle/angular-training-examples/teams","hooks_url":"https://api.github.com/repos/rangle/angular-training-examples/hooks","issue_events_url":"https://api.github.com/repos/rangle/angular-training-examples/issues/events{/number}","events_url":"https://api.github.com/repos/rangle/angular-training-examples/events","assignees_url":"https://api.github.com/repos/rangle/angular-training-examples/assignees{/user}","branches_url":"https://api.github.com/repos/rangle/angular-training-examples/branches{/branch}","tags_url":"https://api.github.com/repos/rangle/angular-training-examples/tags","blobs_url":"https://api.github.com/repos/rangle/angular-training-examples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rangle/angular-training-examples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rangle/angular-training-examples/git/refs{/sha}","trees_url":"https://api.github.com/repos/rangle/angular-training-examples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rangle/angular-training-examples/statuses/{sha}","languages_url":"https://api.github.com/repos/rangle/angular-training-examples/languages","stargazers_url":"https://api.github.com/repos/rangle/angular-training-examples/stargazers","contributors_url":"https://api.github.com/repos/rangle/angular-training-examples/contributors","subscribers_url":"https://api.github.com/repos/rangle/angular-training-examples/subscribers","subscription_url":"https://api.github.com/repos/rangle/angular-training-examples/subscription","commits_url":"https://api.github.com/repos/rangle/angular-training-examples/commits{/sha}","git_commits_url":"https://api.github.com/repos/rangle/angular-training-examples/git/commits{/sha}","comments_url":"https://api.github.com/repos/rangle/angular-training-examples/comments{/number}","issue_comment_url":"https://api.github.com/repos/rangle/angular-training-examples/issues/comments{/number}","contents_url":"https://api.github.com/repos/rangle/angular-training-examples/contents/{+path}","compare_url":"https://api.github.com/repos/rangle/angular-training-examples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rangle/angular-training-examples/merges","archive_url":"https://api.github.com/repos/rangle/angular-training-examples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rangle/angular-training-examples/downloads","issues_url":"https://api.github.com/repos/rangle/angular-training-examples/issues{/number}","pulls_url":"https://api.github.com/repos/rangle/angular-training-examples/pulls{/number}","milestones_url":"https://api.github.com/repos/rangle/angular-training-examples/milestones{/number}","notifications_url":"https://api.github.com/repos/rangle/angular-training-examples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rangle/angular-training-examples/labels{/name}","releases_url":"https://api.github.com/repos/rangle/angular-training-examples/releases{/id}","deployments_url":"https://api.github.com/repos/rangle/angular-training-examples/deployments","created_at":"2016-08-09T14:22:47Z","updated_at":"2016-11-14T16:01:13Z","pushed_at":"2016-11-22T19:37:28Z","git_url":"git://github.com/rangle/angular-training-examples.git","ssh_url":"git@github.com:rangle/angular-training-examples.git","clone_url":"https://github.com/rangle/angular-training-examples.git","svn_url":"https://github.com/rangle/angular-training-examples","homepage":null,"size":176,"stargazers_count":9,"watchers_count":9,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":7,"forks":17,"open_issues":7,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24"},"html":{"href":"https://github.com/rangle/angular-training-examples/pull/24"},"issue":{"href":"https://api.github.com/repos/rangle/angular-training-examples/issues/24"},"comments":{"href":"https://api.github.com/repos/rangle/angular-training-examples/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rangle/angular-training-examples/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/rangle/angular-training-examples/statuses/5d212c946515b44e667c4de2aecd4f626e4c9b97"}}}}
{"actor":{"display_login":"turbobeast"}}