<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var arr = ["a","b","c","d","c","b","a"];
//indexOf从前往后给元素查索引,找到一个后,立刻返回。
console.log(arr.indexOf("a"));
console.log(arr.indexOf("b"));
console.log(arr.indexOf("x"));
//lastIndexOf从后往前给元素查索引,找到一个后,立刻返回。
console.log(arr.lastIndexOf("a"));
console.log(arr.lastIndexOf("b"));
console.log(arr.lastIndexOf("x"));
</script>
</body>
</html>