Skip to content

Instantly share code, notes, and snippets.

@infinitbility
Created July 12, 2020 14:05
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 infinitbility/ba0f69d4d519cac89744a1e805e0f6fe to your computer and use it in GitHub Desktop.
Save infinitbility/ba0f69d4d519cac89744a1e805e0f6fe to your computer and use it in GitHub Desktop.
//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