javascript双等号引起的类型转换,js隐性类型转换步骤
1、截取字符串以对象形式输出
function getUrlParam(localUrl) {
let url = localUrl;
let strs = url.substring(url.indexOf("?") + 1,url.indexOf("#"))
let arrObj = strs.split("&");
console.log(arrObj,'arrObj')
let params = Object.create(null)
if (arrObj.length > 1) {
arrObj.forEach(item => {
item = item.split("=");
params[item[0]] = item[1]
console.log(params,'params')
console.log( params[item[0]],' params[item[0]]')
console.log( item[1],' item[1]')
})
}
return params;
console.log(params,'params')
}
网友评论