deleteEmptyProperties

2020/12/28

深度删除属性值是空(null,undefined,'')的属性

deleteEmptyProperties(obj)

# 参数

  1. obj(Object | Array) :需要删除的数据

# 返回值

(Object | Array)): 删除后的数据

# 例子

import { deleteEmptyProperties } from '@liz-q/utils'

const obj = {
    a: 1,
    b: 2,
    c: '',
    d: null,
    e: undefined,
    f: {
        g: 3,
        h: ''
    },
    i: [4, 5, null, 6]
}
deleteEmptyProperties(obj)
// {
// 	a: 1,
// 	b: 2,
// 	f: {
// 		g: 3
// 	},
// 	i: [4, 5, 6]
// }
Last Updated: 2023/11/13 下午5:46:22