随机产生10个从0-100之间不重复的整数
var arr=[]; for (var i=0;i<100;i++) { arr.push(i); } arr.sort( function(){ return Math.random()-0.5; } ); arr.length=10; console.log(arr);
数组封装indexof()方法
var arr=["字","你","字","哈"]; console.log(arrIndexof(arr,'字')); function arrIndexof(obj,a,b,c){ return obj.join("").indexOf(a,b,c); };