Last active
March 14, 2019 14:00
-
-
Save AhmedBHameed/99e706cfadc96d1ccace5507e027b3da to your computer and use it in GitHub Desktop.
Revisions
-
AhmedBHameed revised this gist
Mar 14, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Those are ES6 helper functions ## ArrayToObjects or ArrayToEntities -
AhmedBHameed revised this gist
Mar 14, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ let arrayToObj = (array, keyField) => Object.assign({}, ...array.map( item => ({ let arrayOfObj = [ {id: 10, name: "Ahmed", age: 29}, {id: 11, name: "Mohameed", age: 36} ]; console.log(arrayToObj(arrayOfObj, "id")); -
AhmedBHameed renamed this gist
Mar 14, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AhmedBHameed created this gist
Mar 14, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ # Those are ES6 heper functions ## ArrayToObjects or ArrayToEntities ```js let arrayToObj = (array, keyField) => Object.assign({}, ...array.map( item => ({[item[keyField]]: item}) )); let arrayOfObj = [ {id: 10, name: "Ahmed", age: 29}, {id: 11, name: "Mohameed", age: 36} ]; console.log(arrayToObj(arrayOfObj, "id")); ```