function removeEmptyStrings(obj) {
for (let key in obj) {
if (obj[key] === '') {
delete obj[key];
}
}
return obj;
}
// 示例用法
let obj = {
name: 'John',
age: '',
occupation: 'Developer',
address: '',
};
console.log(removeEmptyStrings(obj));
输出结果将会是 { name: 'John', occupation: 'Developer' }