lodash检查对象属性有值 [英] lodash check object properties has values
本文介绍了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)
这篇关于lodash检查对象属性有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文