var list = ["apple","banana","orange"]
var index_of_apple = list.indexOf("apple") // 0
let nodes = document.getElementsByTagName('*');
Array.prototype.indexOf.call(nodes, document.body);
let myList = ['foo', 'bar', 'qux'];
myList.indexOf('bar'); // 1
const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];
beasts.indexOf('bison'); //ouput: 1
// start from index 2
beasts.indexOf('bison', 2); //output: 4
beasts.indexOf('giraffe'); //output: -1
// find index of array in javascript
const number = [1,6,2,8,1,0,4,2,7,5,4,1];
const index = number.findIndex(item => item === 8);
console.log(index)
array.indexOf("item");
fruits.push('Mango')
// ["Strawberry", "Banana", "Mango"]
let pos = fruits.indexOf('Banana')
// 1
const index = array.findIndex((param)=> param.name == "jimmy")
/* param will iterate on every value of the array looking for
that one element that fits the criteria that is indicated in arrow function
besides it */
$scope.indexOfField = function(fieldId) {
var fieldData = $scope.model.fieldData,
i = 0, ii = $scope.model.fieldData.length;
for(i; i < ii; i++) if(fieldData[i].Id === fieldId) break;
// use i
}