读书笔记:js中的null 和 undefined 的区别

news/2024/7/19 15:00:49 标签: js, javascript

1.在JS中 null和 undefined 都表示空,但它们还是存在一定区别的, null 表示不存在、没有,而 undefined 表示未定义。

2.底层实现时, null 一般会指向一个全 0 的地址,当 然,这个地址是无法访问的,当遇到这种情况时就会当作不存在来处理; undefined 则表示根本不存在,或者还没有初始化,所以一个变量可以赋值为 null ,但不可赋值为 undefined。


http://www.niftyadmin.cn/n/1367770.html

相关文章

document的只读属性

1. domain: 当前文档的域名2. URL :当前文档 url3. referrer: 当前文档的前一个页面的url4. anchors: 当前文档的所有锚点(a 标签)5. forms :当前文档中的所有表单6. images :当前文…

不想用原生滚动条,用Element-ui隐藏组件el-scrollbar

查看源码接受的props props: {native: Boolean, // 是否启用原生样式;默认falsewrapStyle: {}, wrapClass: {}, // 标签样式 F12 查看viewClass: {}, viewStyle: {},noresize: Boolean, // 如果 container 尺寸不会发生变化,最好设置它可以优化性…

vue 使用 this.$forceUpdate()页面没有刷新

所遇问题: 使用了select、input组件,v-model后值更新了,页面数据未同步change事件调用this.$forceUpdate(),没有效果 解决办法:强制组件重新渲染 // 封装个forceUpdate方法 // 子组件在change调用 this.$emit(forceUpdate) // …

vue 、 在element-ui的el-table组件中 使用 el-select绑定对象时value-key的注意事项

// 绑定对象时设置了value-key,再次点击时不会高亮,找了源码发现key需要一致; // 相关源码 isEqual(a, b) {if (!this.isObject) {return a b;} else {const valueKey this.select.valueKey;return getValueByPath(a, valueKey) getValueByPath(b, va…

如何将浏览器中的坐标转换为 canvas 中的坐标

function convertToCanvas(canvas, x, y} {const canvasElement canvas.getBoundingClientRect() ;return { x: (x- canvasElement.left)*(canvas.width / canvasElement.width),y: (y - canvasElement.top)*(canvas.height / canvasElement.height)} }转换的逻辑是先使用鼠…

js浏览器版本判断

// 判断是否为IE浏览器 function isIE () {const bw window.navigator.userAgent// ie版本 10 及以下const compare (s) > bw.indexOf(s) > 0// ie 11const ie11 (() > ActiveXObject in window)()return compare(MSIE) || ie11 } isChrome() {const e navigator.…

vue动态路由刷新后无限循环、页面空白

使用的是PanJiaChen大佬的vue-admin-template模板 下载大佬的权限管理模板运行正常,自己用来改造刷新就无限循环or页面空白,下面是改造成功的permission.js相关代码 // !!!自己项目不需要token const hasGetUserInfo…

vue倒计时60秒

// _cutime 60resetTime(){let timerconst countDown ()>{this.time--;if(this.time < 0){clearInterval(timer);this.time _cutimethis.$forceUpdate()return}timersetTimeout(countDown,1000);}countDown()},