码迷,mamicode.com
首页 > 编程语言 > 详细

Javascript中的null和 undefined

时间:2019-03-12 21:17:03      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:inf   assigned   call   undefined   value   AMM   str   pre   use   

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

标签:inf   assigned   call   undefined   value   AMM   str   pre   use   

原文地址:https://www.cnblogs.com/eret9616/p/10519615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!