js如何将字符串'https://www.qq.com/s?name=laoxie&age=18&sex=male&'转成对象?

将字符串'https://www.qq.com/s?name=laoxie&age=18&sex=male&'转成对象{name:'laoxie',age:18,sex:male}输出;
var str = 'https://www.qq.com/s?name=laoxie&age=18&sex=male&';
	var arr =str.split("?")[1];//取?后面的字段
		var res = arr.split("&",3);//以&为分割,并取下标为0至2的部分,去掉空“”;
	var json = {};
	for(var i =0;i

你可能感兴趣的:(技术分享)