转成数组的通用函数
1 var toArray = function(s){ 2 try{ 3 return Array.prototype.slice.call(s); 4 } catch(e){ 5 var arr = []; 6 for(var i = 0,len = s.length; i < len; i++){ 7 //arr.push(s[i]); 8 arr[i] = s[i]; //据说这样比push快 9 } 10 return arr; 11 } 12 }
转成数组的通用函数
1 var toArray = function(s){ 2 try{ 3 return Array.prototype.slice.call(s); 4 } catch(e){ 5 var arr = []; 6 for(var i = 0,len = s.length; i < len; i++){ 7 //arr.push(s[i]); 8 arr[i] = s[i]; //据说这样比push快 9 } 10 return arr; 11 } 12 }