lodash检查对象属性有值

问题描述:

我有几个属性的对象,说它是这样的

I have object with several properties, says it's something like this

{ a: "", b: undefined }

在jsx中是否存在任何一行解决方案我可以检查该对象的属性是否为空或具有值或不?如果数组有一个isEmpty方法。

in jsx is there any one line solution I can check whether that object's property is not empty or has value or not? If array there's a isEmpty method.

我试过这个

const somethingKeyIsnotEmpty = Object.keys((props.something, key, val) => {
        return val[key] !== '' || val[key] !== undefined
})


在lodash中,你可以使用_.some

In lodash, you can use _.some

_.some(props.something, _.isEmpty)