{"action":"created","comment":{"url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/comments/77532523","id":77532523,"diff_hunk":"@@ -3268,6 +3269,95 @@ Use [Gulp](http://gulpjs.com) or [Grunt](http://gruntjs.com) for creating automa\n \n **[Back to top](#table-of-contents)**\n \n+## Low Level Functions\n+\n+Angular 1.x ships with some [helper functions](https://docs.angularjs.org/api/ng/function) that are found within JavaScript natively. In such cases we should favor usage of native JavaScript functions instead of Angular's helper functions. In other cases where functionality is not found in JavaScript natively, we should turn to utility libraries such as [lodash](https://lodash.com/docs) to fill-in the gaps.\n+\n+###### [Style [Y500](#style-y500)]\n+\n+  - Avoid using Angular low-level functions such as `angular.copy()`, `angular.extend()` or even `angular.isUndefined()`.\n+\n+  *Why?*: You can replace a lot Angular's low-level functions with native ES2015+ functionality such as [`Object.assign()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) for copying objects and the [Spread Syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Copy_an_array) for copying arrays _(ie. `[...arr1]`)_.\n+\n+  *Why?*: Because this is functionality that has been made available in the latest versions of JavaScript, but did not exist natively back when helper functions were first written.\n+\n+  Replace `angular.forEach()` and `angular.isArray()`:\n+\n+  ```javascript\n+  /* avoid */\n+  var arr = [1, 2, 3];\n+  var obj = { hello: 'Hello', world: 'World' };\n+\n+  angular.forEach(arr, function(value) {\n+    console.log(value);\n+  });\n+\n+  angular.forEach(obj, function(value) {\n+    console.log(value);\n+  });\n+\n+  angular.isArray(arr); // true\n+  angular.isArray(obj); // false\n+  ```\n+\n+  ```javascript\n+  /* recommended */\n+  var arr = [1, 2, 3];\n+  var obj = { hello: 'Hello', world: 'World' };\n+\n+  // iterate through arrays\n+  arr.forEach(function(value) {\n+    console.log(value);\n+  });\n+\n+  // iterate through objects\n+  Object.keys(obj)\n+    .forEach(function(key) {\n+      console.log(obj[key]);\n+    });\n+\n+  // alternative lodash helper to iterate through objects\n+  _.forEach(obj, function(value) {\n+    console.log(value);\n+  });\n+\n+  // available in ES\n+  Array.isArray(arr); // true\n+  Array.isArray(obj); // false\n+  ```\n+\n+  Don't use `angular.copy()` and `angular.extend()` in favor of ES2015 features:\n+\n+  ```javascript\n+  /* avoid */\n+  var arr1 = [1, 2, 3];\n+  var arr2 = angular.copy(arr1); // [1, 2, 3]\n+\n+  var obj1 = { hello: 'Hello' };\n+  var obj2 = { world: 'World' };\n+  var obj3 = angular.extend({}, obj1, obj2); // {hello: 'Hello', world: 'World'}","path":"a1/README.md","position":78,"original_position":78,"commit_id":"c93732e7a7819b062c1ea00f23a9a70f2abe064d","original_commit_id":"df1453c0cd519635a4072249af87f9958d9cc938","user":{"login":"sergiocruz","id":1854949,"avatar_url":"https://avatars.githubusercontent.com/u/1854949?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocruz","html_url":"https://github.com/sergiocruz","followers_url":"https://api.github.com/users/sergiocruz/followers","following_url":"https://api.github.com/users/sergiocruz/following{/other_user}","gists_url":"https://api.github.com/users/sergiocruz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocruz/subscriptions","organizations_url":"https://api.github.com/users/sergiocruz/orgs","repos_url":"https://api.github.com/users/sergiocruz/repos","events_url":"https://api.github.com/users/sergiocruz/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocruz/received_events","type":"User","site_admin":false},"body":"I added a note for this later in the block advising people to understand the differences in implementation.","created_at":"2016-09-05T14:50:39Z","updated_at":"2016-09-05T14:50:39Z","html_url":"https://github.com/johnpapa/angular-styleguide/pull/768#discussion_r77532523","pull_request_url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768","_links":{"self":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/comments/77532523"},"html":{"href":"https://github.com/johnpapa/angular-styleguide/pull/768#discussion_r77532523"},"pull_request":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768"}}},"pull_request":{"url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768","id":83925961,"html_url":"https://github.com/johnpapa/angular-styleguide/pull/768","diff_url":"https://github.com/johnpapa/angular-styleguide/pull/768.diff","patch_url":"https://github.com/johnpapa/angular-styleguide/pull/768.patch","issue_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/768","number":768,"state":"open","locked":false,"title":"Adds block about Angular's low-level functions","user":{"login":"sergiocruz","id":1854949,"avatar_url":"https://avatars.githubusercontent.com/u/1854949?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocruz","html_url":"https://github.com/sergiocruz","followers_url":"https://api.github.com/users/sergiocruz/followers","following_url":"https://api.github.com/users/sergiocruz/following{/other_user}","gists_url":"https://api.github.com/users/sergiocruz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocruz/subscriptions","organizations_url":"https://api.github.com/users/sergiocruz/orgs","repos_url":"https://api.github.com/users/sergiocruz/repos","events_url":"https://api.github.com/users/sergiocruz/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocruz/received_events","type":"User","site_admin":false},"body":"Angular 1.x low-level functions should be avoided in favor of language features that are available natively in its newest versions (ES2015+). For most other cases a utility library like lodash will do wonders as well.\r\n\r\nAlthough it was not mentioned in the guide, avoiding low-level also helps when upgrading to Angular 2. With the help of TypeScript and newest language features, Angular 2 is able to shift more responsibility to the language itself. Therefore functions like `angular.copy()`, `angular.isUndefined()` and `angular.equals()` is simply not found within Angular 2.","created_at":"2016-09-04T15:34:17Z","updated_at":"2016-09-05T14:50:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59e33f436ac511b1922080f073640413bf621dcb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768/commits","review_comments_url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768/comments","review_comment_url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/768/comments","statuses_url":"https://api.github.com/repos/johnpapa/angular-styleguide/statuses/c93732e7a7819b062c1ea00f23a9a70f2abe064d","head":{"label":"sergiocruz:master","ref":"master","sha":"c93732e7a7819b062c1ea00f23a9a70f2abe064d","user":{"login":"sergiocruz","id":1854949,"avatar_url":"https://avatars.githubusercontent.com/u/1854949?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocruz","html_url":"https://github.com/sergiocruz","followers_url":"https://api.github.com/users/sergiocruz/followers","following_url":"https://api.github.com/users/sergiocruz/following{/other_user}","gists_url":"https://api.github.com/users/sergiocruz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocruz/subscriptions","organizations_url":"https://api.github.com/users/sergiocruz/orgs","repos_url":"https://api.github.com/users/sergiocruz/repos","events_url":"https://api.github.com/users/sergiocruz/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocruz/received_events","type":"User","site_admin":false},"repo":{"id":67350370,"name":"angular-styleguide","full_name":"sergiocruz/angular-styleguide","owner":{"login":"sergiocruz","id":1854949,"avatar_url":"https://avatars.githubusercontent.com/u/1854949?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocruz","html_url":"https://github.com/sergiocruz","followers_url":"https://api.github.com/users/sergiocruz/followers","following_url":"https://api.github.com/users/sergiocruz/following{/other_user}","gists_url":"https://api.github.com/users/sergiocruz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocruz/subscriptions","organizations_url":"https://api.github.com/users/sergiocruz/orgs","repos_url":"https://api.github.com/users/sergiocruz/repos","events_url":"https://api.github.com/users/sergiocruz/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocruz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sergiocruz/angular-styleguide","description":"Angular Style Guide: A starting point for Angular development teams to provide consistency through good practices.","fork":true,"url":"https://api.github.com/repos/sergiocruz/angular-styleguide","forks_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/forks","keys_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/teams","hooks_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/hooks","issue_events_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/issues/events{/number}","events_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/events","assignees_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/assignees{/user}","branches_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/branches{/branch}","tags_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/tags","blobs_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/git/refs{/sha}","trees_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/statuses/{sha}","languages_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/languages","stargazers_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/stargazers","contributors_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/contributors","subscribers_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/subscribers","subscription_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/subscription","commits_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/commits{/sha}","git_commits_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/git/commits{/sha}","comments_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/comments{/number}","issue_comment_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/issues/comments{/number}","contents_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/contents/{+path}","compare_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/merges","archive_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/downloads","issues_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/issues{/number}","pulls_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/pulls{/number}","milestones_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/milestones{/number}","notifications_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/labels{/name}","releases_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/releases{/id}","deployments_url":"https://api.github.com/repos/sergiocruz/angular-styleguide/deployments","created_at":"2016-09-04T14:43:49Z","updated_at":"2016-09-04T14:25:48Z","pushed_at":"2016-09-05T14:49:47Z","git_url":"git://github.com/sergiocruz/angular-styleguide.git","ssh_url":"git@github.com:sergiocruz/angular-styleguide.git","clone_url":"https://github.com/sergiocruz/angular-styleguide.git","svn_url":"https://github.com/sergiocruz/angular-styleguide","homepage":"http://johnpapa.net","size":3959,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"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":"johnpapa:master","ref":"master","sha":"42185df50e66007e11c88826a4b8784764b5977c","user":{"login":"johnpapa","id":1202528,"avatar_url":"https://avatars.githubusercontent.com/u/1202528?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpapa","html_url":"https://github.com/johnpapa","followers_url":"https://api.github.com/users/johnpapa/followers","following_url":"https://api.github.com/users/johnpapa/following{/other_user}","gists_url":"https://api.github.com/users/johnpapa/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpapa/subscriptions","organizations_url":"https://api.github.com/users/johnpapa/orgs","repos_url":"https://api.github.com/users/johnpapa/repos","events_url":"https://api.github.com/users/johnpapa/events{/privacy}","received_events_url":"https://api.github.com/users/johnpapa/received_events","type":"User","site_admin":false},"repo":{"id":22362099,"name":"angular-styleguide","full_name":"johnpapa/angular-styleguide","owner":{"login":"johnpapa","id":1202528,"avatar_url":"https://avatars.githubusercontent.com/u/1202528?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpapa","html_url":"https://github.com/johnpapa","followers_url":"https://api.github.com/users/johnpapa/followers","following_url":"https://api.github.com/users/johnpapa/following{/other_user}","gists_url":"https://api.github.com/users/johnpapa/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpapa/subscriptions","organizations_url":"https://api.github.com/users/johnpapa/orgs","repos_url":"https://api.github.com/users/johnpapa/repos","events_url":"https://api.github.com/users/johnpapa/events{/privacy}","received_events_url":"https://api.github.com/users/johnpapa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnpapa/angular-styleguide","description":"Angular Style Guide: A starting point for Angular development teams to provide consistency through good practices.","fork":false,"url":"https://api.github.com/repos/johnpapa/angular-styleguide","forks_url":"https://api.github.com/repos/johnpapa/angular-styleguide/forks","keys_url":"https://api.github.com/repos/johnpapa/angular-styleguide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnpapa/angular-styleguide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnpapa/angular-styleguide/teams","hooks_url":"https://api.github.com/repos/johnpapa/angular-styleguide/hooks","issue_events_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/events{/number}","events_url":"https://api.github.com/repos/johnpapa/angular-styleguide/events","assignees_url":"https://api.github.com/repos/johnpapa/angular-styleguide/assignees{/user}","branches_url":"https://api.github.com/repos/johnpapa/angular-styleguide/branches{/branch}","tags_url":"https://api.github.com/repos/johnpapa/angular-styleguide/tags","blobs_url":"https://api.github.com/repos/johnpapa/angular-styleguide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnpapa/angular-styleguide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnpapa/angular-styleguide/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnpapa/angular-styleguide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnpapa/angular-styleguide/statuses/{sha}","languages_url":"https://api.github.com/repos/johnpapa/angular-styleguide/languages","stargazers_url":"https://api.github.com/repos/johnpapa/angular-styleguide/stargazers","contributors_url":"https://api.github.com/repos/johnpapa/angular-styleguide/contributors","subscribers_url":"https://api.github.com/repos/johnpapa/angular-styleguide/subscribers","subscription_url":"https://api.github.com/repos/johnpapa/angular-styleguide/subscription","commits_url":"https://api.github.com/repos/johnpapa/angular-styleguide/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnpapa/angular-styleguide/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnpapa/angular-styleguide/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnpapa/angular-styleguide/contents/{+path}","compare_url":"https://api.github.com/repos/johnpapa/angular-styleguide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnpapa/angular-styleguide/merges","archive_url":"https://api.github.com/repos/johnpapa/angular-styleguide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnpapa/angular-styleguide/downloads","issues_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues{/number}","pulls_url":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls{/number}","milestones_url":"https://api.github.com/repos/johnpapa/angular-styleguide/milestones{/number}","notifications_url":"https://api.github.com/repos/johnpapa/angular-styleguide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnpapa/angular-styleguide/labels{/name}","releases_url":"https://api.github.com/repos/johnpapa/angular-styleguide/releases{/id}","deployments_url":"https://api.github.com/repos/johnpapa/angular-styleguide/deployments","created_at":"2014-07-29T00:07:51Z","updated_at":"2016-09-05T14:35:56Z","pushed_at":"2016-09-05T14:49:51Z","git_url":"git://github.com/johnpapa/angular-styleguide.git","ssh_url":"git@github.com:johnpapa/angular-styleguide.git","clone_url":"https://github.com/johnpapa/angular-styleguide.git","svn_url":"https://github.com/johnpapa/angular-styleguide","homepage":"http://johnpapa.net","size":5798,"stargazers_count":20195,"watchers_count":20195,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3610,"mirror_url":null,"open_issues_count":83,"forks":3610,"open_issues":83,"watchers":20195,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768"},"html":{"href":"https://github.com/johnpapa/angular-styleguide/pull/768"},"issue":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/768"},"comments":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/768/comments"},"review_comments":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768/comments"},"review_comment":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/pulls/768/commits"},"statuses":{"href":"https://api.github.com/repos/johnpapa/angular-styleguide/statuses/c93732e7a7819b062c1ea00f23a9a70f2abe064d"}}}}
{"actor":{"display_login":"sergiocruz"}}