// ECMAScript 5 为数组实例添加了两个位置方法: indexOf()和 lastIndexOf()。这两个方法都接收两个参数:要查找的项和(可选的)表示查找起点位置的索引。其中, indexOf()方法从数组的开头(位置 0)开始向后查找, lastIndexOf()方法则从数组的末尾开始向前查找。
var numbers = [1,2,3,4,5,4,3,2,1];
console.log(numbers.indexOf(2)); // 1
console.log(numbers.lastIndexOf(3)); // 6
console.log(numbers.indexOf(2, 5)); // 7
console.log(numbers.lastIndexOf(3, 4)); // 2
var person = {name: "Bobi"};
var people = [{name: "Bobi"}];
var morePeople = [person];
console.log(people.indexOf(person)); // -1
console.log(people === morePeople); // false
console.log(morePeople.indexOf(person)); // 0
console