Last active
November 14, 2016 15:18
-
-
Save umair-khanzada/085dc8cba17a0d6b8f7307275c230318 to your computer and use it in GitHub Desktop.
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 characters
| let array = [{ id: 1, name: 'umair', age: 14 }, { id: 2, name: 'zubair', age: 16 }, { id: 3, name: 'owais', age: 20 }]; | |
| //get any field/key of obj using map. | |
| let idsArray = array.map( (obj) => obj.id ); | |
| //result ids = [1, 2, 3] | |
| //get special object from array using find. | |
| let specialObj = array.find( (obj) => obj.name == 'umair' ); | |
| //result specialObj = {id: 1, name: "umair", age: 14} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment