1. 程式人生 > >Javascript中的null和 undefined

Javascript中的null和 undefined

don prot type hand declared pro sed 分享圖片 null

Javascript Undefined vs NULL

Many a times we often get confused on whats the difference between UNDEFINED and NULL. undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value. undefined指一個變量被聲明但是沒有賦值, null是一個用來賦值的變量,可以分配到一個變量, 意味這個變量沒有值 Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object. undined和null是完全不同的類型, undefined是一個類型(undefined 類型) , null是一個對象 Unassigned variables are initialized by JavaScript with a default value of undefined. JavaScript never sets a value to null. That must be done programmatically. JavaScript的未初始化的變量默認值是undefined, 一般null都是人手工分配的(不過Object原型對象 的__proto__好像也是null) 技術分享圖片
undefined是一個value null 是一個對象 技術分享圖片


Javascript中的null和 undefined