Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Created March 7, 2021 06:39
Show Gist options
  • Save sharmaabhinav/d04ef3ba60562122b2336da477343115 to your computer and use it in GitHub Desktop.
Save sharmaabhinav/d04ef3ba60562122b2336da477343115 to your computer and use it in GitHub Desktop.
Find an element in the list of user objects based on Id
const list = [
{
Id: 1,
Name: “A”
},
{
Id: 2,
Name: “B”
},
{
Id: 3,
Name: “C”
},
]
list.findById(2)
Output = {
Id: 2,
Name: “B”
}
Flatten an Array
const list = [1,2,3,4, [5,6,[7,8]], 9,10]
list.flatten
Output = [1,2,3,4,5,6,7,8,9,10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment