Checking something isEmpty in Javascript?

后端 未结 18 2525
天涯浪人
天涯浪人 2020-12-12 12:38

How can I check if a variable is empty in Javascript? Sorry for the stupid question, but I\'m a newbie in Javascript!

if(response.photo) is empty {
    do so         


        
18条回答
  •  天命终不由人
    2020-12-12 13:01

    what am I missing if empty array... keyless object... falseness const isEmpty = o => Array.isArray(o) && !o.join('').length || typeof o === 'object' && !Object.keys(o).length || !(+value);

提交回复
热议问题