给一个字符串str = "id=10&name=小明&age=18&sex=男"
要求:分隔字符串变成的效果{ id: 10, name : 小明, age : 18, sex : 男 }
var str3 = {};
var str ="id=10&name=小明&age=18&sex=男";
str2 =String(str.split("&"));
str4 = String(str2.split("="));
str5 = str4.split(",");
console.log(str5);
for (var i =0;i<str5.length;i++){
var key = str5[i];
str3[key] = str5[i+1];
i++;
}
console.log(str3);//{id: "10", name: "小明", age: "18", sex: "男"}