<div class="htmlarea"> <textarea id="runcode36419"> <script type="text/javascript"> //<![CDATA[ [].indexOf || (Array.prototype.indexOf = function(v){ for(var i = this.length; i-- && this[i] !== v;); return i; }); var b = [0, 1, '哈哈', 3, 4, '嘿嘿', 6, 7, 8, 9]; document.write("<br>b = ", b.join(","), "<br>"); document.write("<br>b.indexOf(2) = ", b.indexOf(2)); document.write("<br>b.indexOf('嘿嘿') = ", b.indexOf('嘿嘿')); //]]> </script> </textarea><br><input onclick="runEx('runcode36419')" type="button" value="运行代码"> <input onclick="doCopy('runcode36419')" type="button" value="复制代码"> <input onclick="doSave(runcode36419)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br>运行以上代码,即可。<br>如果大家想看的是 javascript indexOf的使用方法,请看下面的文章<br><a href="http://www.jb51.net/article/15050.htm" target="_blank">javascript indexOf函数使用说明</a><br><a href="http://www.jb51.net/article/17543.htm" target="_blank">JavaScript indexOf忽略大小写_javascript技巧</a>