冰冰点灯
照亮我的家门
 1 <!DOCTYPE html>
 2 <html>
 3 <head lang="en">
 4     <meta charset="UTF-8">
 5     <title></title>
 6 </head>
 7 <body>
 8 <script>
 9 
10     var arr = ["a","b","c","d","c","b","a"];
11 
12     //indexOf从前往后给元素查索引,找到一个后,立刻返回。
13     console.log(arr.indexOf("a"));
14     console.log(arr.indexOf("b"));
15     console.log(arr.indexOf("x"));
16 
17     //lastIndexOf从后往前给元素查索引,找到一个后,立刻返回。
18     console.log(arr.lastIndexOf("a"));
19     console.log(arr.lastIndexOf("b"));
20     console.log(arr.lastIndexOf("x"));
21 
22 
23 
24 
25 </script>
26 </body>
27 </html>

 

posted on 2019-01-16 17:06  冰冰点灯  阅读(188)  评论(0编辑  收藏  举报