var aa = '?name=hss&age=13';
function strtoobj(str){
if(typeof str === 'undefined'){
str = location.search;
}
var reg = /[\?|&]+(\w+)=(\w*)/g;
var param = {};
do{
var item = reg.exec(str);
if(item !== null){
param[item[1]] = item[2]
}
}while(reg.lastindex > 0)
return param;
}
console.time()
console.log(strtoobj());
console.timeend()
执行效率还是蛮高的大概在一毫秒吧
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论