1. 时间复杂度O(n)
2. split3次 ? & =
3. 结果用reduce聚合
const _getParams = (url) => {
// 补全代码
const i = url.lastIndexOf('?');
const queryStr = i > -1 ? url.slice(i + 1) : '';
return queryStr.split('&').reduce((tmp, str) => {
let [k, v] = str.split('=');
tmp[k] = v;
return tmp;
}, {});
}



京公网安备 11010502036488号