深入JavaScript Day08 - with、eval、s
作者:
望穿秋水小作坊 | 来源:发表于
2022-01-14 11:16 被阅读0次
一、with、eval、strict model(严格模式)
1、【了解】with语句

image.png
2、eval函数的作用?

image.png
3、strict mode 是干啥的?

image.png

image.png

image.png
4、严格模式,对默认绑定的this有什么影响吗?
function foo() {
console.log(this); //输出 window对象
}
foo();
"use strict";
function foo() {
console.log(this); //输出 undefined
}
foo();
二、Object.defineProperties
1、如果我们需要对一个对象的属性做一些限制,比如不允许被删除、不允许被修改、不允许被遍历出来。要怎么做?
- 借助
Object.defineProperties 可以实现对象属性的精准控制

image.png
2、Object.defineProperties 属性描述符有两种,是哪两种?

image.png

image.png

image.png

image.png

image.png
3、如何一次定义多个属性描述符呢?

image.png
4、如何获取对象的属性描述符?

image.png
本文标题:深入JavaScript Day08 - with、eval、s
本文链接:https://www.haomeiwen.com/subject/qpdacrtx.html
网友评论