Checking something isEmpty in Javascript?

后端 未结 18 2552
天涯浪人
天涯浪人 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:05

    See http://underscorejs.org/#isEmpty

    isEmpty_.isEmpty(object) Returns true if an enumerable object contains no values (no enumerable own-properties). For strings and array-like objects _.isEmpty checks if the length property is 0.

提交回复
热议问题