null in JavaScript

C# String.IsNullOrEmpty Javascript equivalent

https://stackoverflow.com/questions/5746947/c-sharp-string-isnullorempty-javascript-equivalent

if(!theString) {
 alert("the string is null or empty");
}

 

扩展

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null

typeof null          // "object" (not "null" for legacy reasons)
typeof undefined     // "undefined"
null === undefined   // false
null  == undefined   // true
null === null        // true
null == null         // true
!null                // true
isNaN(1 + null)      // false
isNaN(1 + undefined) // true

 

posted @ 2018-03-15 17:59  ChuckLu  阅读(239)  评论(0)    收藏  举报