lodash check object properties has values

后端 未结 3 1404
北海茫月
北海茫月 2021-01-11 09:46

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

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 10:22

    You can use lodash _.every and check if _.values are _.isEmpty

    const profile = {
      name: 'John',
      age: ''
    };
    
    const emptyProfile = _.values(profile).every(_.isEmpty);
    
    console.log(emptyProfile); // returns false
    

提交回复
热议问题