当前位置:网站首页>The difference between null and undefined
The difference between null and undefined
2022-04-23 07:34:00 【XIX (procrastination)】
null and undefined The difference between
null: Represents an empty object
undefined: Represents that the variable is not assigned
summary :
- When a variable is defined but no value is assigned , Output undefined
- The variable can be specified as null, But not assigned to undefined
- When the variable is set to null when , The type is object
Example :
️: When a variable is defined but not assigned a value , Output undefined.
var a;
console.log(a)
output:undefined
If you don't create a variable, use it , Output a is not defined
console.log(a)
output:Uncaught ReferenceError: a is not defined;
️: When assigning a value to a variable :
It can be assigned to null,
But it cannot be assigned to undefined
var a = undefind;
console.log(a)
output:undefind is not defined
var a = null;
console.log(a)
output:null
When the variable is set to null when , The type is object
var a = null;
console.log(typeof a)
output:object
版权声明
本文为[XIX (procrastination)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230618085425.html
边栏推荐
猜你喜欢
随机推荐
通用型冒泡、选择、插入、希尔、快速排序的代码实现
开发板如何ping通百度
可视化常见绘图(一)堆叠图
带您遨游太空,美摄科技为航天创意小程序提供全面技术支持
PyTorch 11. Regularization
商业版阿里MQ普通消息发送订阅Demo
美摄科技云剪辑,助力哔哩哔哩使用体验再升级
Discussion on frame construction and technology selection of short video platform
免费开源智能充电桩物联网SAAS云平台
社区版阿里MQ普通消息发送订阅Demo
Jupyter Notebook 安装
el-select 中v-model绑定值,数据回显只显示value,不显示label
记录阿里云服务器挖矿程序处理
小程序wx.previewMedia相关问题解决-日常踩坑
javscript获取文件真实后缀名
STM32多路测温无线传输报警系统设计(工业定时测温/机舱温度定时检测等)
可视化常见绘图(三)面积图
Machine vision series (02) -- tensorflow2 3 + win10 + GPU installation
防汛救灾应急通信系统
el-date-picker中自定义快捷选项picker-options,动态设置禁用日期