<script>
//indexOf()返回第一个符合的数组下标,如果在里面找不到,就返回-1
var a = ["red", "green", "blue", "blue"];
console.log(a.indexOf("blue"));
console.log(a.indexOf("pink"));
//lastIndexOf返回的是最后一个符合的数组下标,如果找不到就返回-1
console.log(a.lastIndexOf('blue'));
console.log(a.lastIndexOf('pink'));
</script>
运行结果: