Monday, May 20, 2024
76
rated 0 times [  81] [ 5]  / answers: 1 / hits: 57281  / 7 Years ago, fri, july 7, 2017, 12:00:00

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



{ a: , b: undefined }


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.



I tried this



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

More From » ecmascript-6

 Answers
17

In lodash, you can use _.some



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

[#57184] Tuesday, July 4, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marinalyssak

Total Points: 637
Total Questions: 101
Total Answers: 94

Location: Morocco
Member since Fri, May 22, 2020
4 Years ago
;