export const filterParams = (obj) => {
let newObj = {};
for (const key in obj) {
//如果对象属性的值不为空,就保存该属性(如果属性的值为0 false,保存该属性。如果属性的值全部是空格,属于为空。)
if ((obj[key] === 0 || obj[key] === false || obj[key]) && obj[key].toString().replace(/(^\s*)|(\s*$)/g, '') !== '') {
newObj[key] = obj[key];
}
}
return newObj;
}
标签:newObj,obj,undefined,js,key,false,null,属性
From: https://www.cnblogs.com/ZerlinM/p/16984403.html