JavaScript null and undefined

http://stackoverflow.com/questions/6429225/javascript-null-or-undefined

var x; x == null // true x == undefined // true x === null // false x === undefined // true var y = null; y == null // true y == undefined // true y === null // true y === undefined // false typeof x // 'undefined' typeof y // 'object' var z = {abc: null}; z.abc == null // true z.abc == undefined // true z.abc === null // true z.abc === undefined // false z.xyz == null // true z.xyz == undefined // true z.xyz === null // false z.xyz === undefined // true null = 1; // throws error: invalid left hand assignment undefined = 1; // works fine: this can cause some problems
posted @ 2014-07-19 11:10  webglcn  阅读(198)  评论(0编辑  收藏  举报