Tuesday, August 2, 2011

javascript undefined

var a;
var b = null;
var c = "";
// d is not declare



//  var a;
typeof(a)                           return undefined
a == undefined                 return true
a === undefined               return true

// var b = null;
typeof(b)                           return object
b == undefined                 return true
b === undefined               return false

// var c = "";
typeof(c)                           return string
c == undefined                 return false
c === undefined               return false

// d is no declare
typeof(d)                           return undefined
d == undefined                 throw exception
d === undefined               throw exception