读书人

JavaScript - null VS undefined

发布时间: 2012-09-10 22:20:13 作者: rapoo

JavaScript ---- null VS undefined
共同点:
1, null and undefined both indicate an absence of value.
2. Both are falsy values-----they behave like false when a boolean value is required.
3. Neither null or undefined have any properties or methods.

不同点:
1. The equality operator== considers them to be equal.
Use the strict equality operator === to distinguish them
2. You might consider undefined to represent a system-level, unexpected, or error-like absence of value.
Null to represent program-level, normal, or expected absence of value.

读书人网 >VSTS

热点推荐