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()
执行效率还是蛮高的大概在一毫秒吧