SOURCE

function getUrlParams(url, key) {
    let result = {}
    let reg = /(\w+)=(\w+)/g
    while (reg.exec(url)) {
        let key = RegExp.$1,
            value = RegExp.$2
        result[key] = result[key] ? [...result[key], value] : value
    }
    return key ? (result[key] || "") : result
}


let res = getUrlParams("https://juejin.cn/post/6844903666000904205?a=1&a=2&a=3&b=4", "a")

console.log(res)
console 命令行工具 X clear

                    
>
console