去掉对象中值为null和undefined的空字段
作者:互联网
const v1 = {
a: '1',
b: 20,
c: null,
d: undefined,
}
const v1 = {
a: '1',
b: 20,
}
const params = Object.keys(data) .filter((key) => data[key] !== null && data[key] !== undefined) .reduce((acc, key) => ({ ...acc, [key]: data[key] }), {});
https://www.jianshu.com/p/4d76644b0e42
标签:const,undefined,v1,key,null,data,空字段 来源: https://www.cnblogs.com/zihang-cheng/p/16614721.html