Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//indexOf example
var fruits = ['Banana', 'Blackcurrant', 'Blueberry', 'Chili pepper', 'Cranberry', 'Eggplant', 'Gooseberry'];
// You get their index ( Key )
var index = fruits.indexOf('Blueberry');
// output 2
// if value not available
var index = fruits.indexOf('Apple');
// output -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment