SOURCE

var data = {
    name:'23123',
    age:36,
    sex:"man",
    ashjk:''
}

function serialize (data) {
    var url = 'asdasd?'
    for(let i in data){
        let value = data[i] != undefined ? data[i] :""
        url +=  `&${i}=${data[i]}`
    }
    return url ? url.slice(1) :"" //去掉第一个&
}

// function serialize(data) {
//     let url = "";
//     for (let k in data) {
//         let value = data[k] != undefined ? data[k] : '';
//         url += `&${k}=${encodeURIComponent(value)}`;
//     }
//     return url ? url.slice(1) : '';
// }


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

                    
>
console