Skip to content

Instantly share code, notes, and snippets.

@trey
Created April 12, 2016 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trey/3a5c3cafe0e44e3674683396a0bd7993 to your computer and use it in GitHub Desktop.
Save trey/3a5c3cafe0e44e3674683396a0bd7993 to your computer and use it in GitHub Desktop.
Find an object by a value in a JavaScript array.
var optionList = [
    {
        'label': 'HTML',
        'value': 'html'
    },
    {
        'label': 'Plain Text',
        'value': 'plaintext'
    }
];

console.log(optionList.find(option => option.value === 'html'));
@trey
Copy link
Author

trey commented Apr 12, 2016

This is a Solutions Log post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment