标签:方法 art typeof class [] array 数组 var on()
function strToArray(parm){ var newArr; if(typeof parm == ‘string‘){ [].forEach.call(parm,function(v,i,arr){ if(i === 0){ newArr = [].slice.call(arr); } }) } return newArr || []; }
// strToArray("adsfssfsdsf")
// ["a", "d", "s", "f", "s", "s", "f", "s", "d", "s", "f"]
// 方法二 var toArray = function(){ return isIE ? function(a, i, j, res){ res = []; [].forEach.call(a, function(v) { res.push(v); }); return res.slice(i || 0, j || res.length); } : function(a, i, j){ return Array.prototype.slice.call(a, i || 0, j || a.length); } }()
来自://http://www.jb51.net/article/23332.htm
标签:方法 art typeof class [] array 数组 var on()
原文地址:http://www.cnblogs.com/zhujiasheng/p/6388829.html