function deleteEmptyProperty(obj){ var object = obj; for (var i in object) { var value = object[i]; if (typeof value === ‘object‘) { if (Array.isArray(value)) { if (value.length == 0) { delete object[i]; continue; } } this.deleteEmptyProperty(value); } else { if (value === ‘‘ || value === null || value === undefined) { delete object[i]; } } } return object; }
原文地址:https://www.cnblogs.com/hfultrastrong/p/9708771.html
时间: 2024-10-16 15:28:48