setTimeout(()=>{
console.log(4)
})
new Promise(resolve=>{
resolve()
console.log(1);
}).then(()=>{
console.log(3);
})
cnosle.log(2)
1,2,3,4
考察对虚拟DOM的理解
考察引用类型的传值方式
var a,b,c;
a = [1,7];
b = a;
b[0] = 6;
c = b;
c[1] = 9;
console.log(a)
这里数组是引用数据类型,画个图方便理解:
这个在xx技术2023前端开发卷A第29题。
Function.prototype.before = function (beforeFn) {
return () => {
beforeFn.apply(this, arguments)
return this.apply(this, arguments)
}
}
Function.prototype.after = function (afterFn) {
return () => {
var ret = this.apply(this, arguments);
afterFn.apply(this, arguments)
return ret
}
}
func = function () {
console.log(2);
}.before(function () {
console.log(1);
}).after(function () {
console.log(3);
})
func();
1,2,3
Object.keys(obj)
,Object.getOwnPropertyNames(obj)
,Relfect.ownKeys(obj)
三者的区别。var obj = { a: "1", b: "2" };
Object.prototype.protoName = "proto foobar";
var foo = Symbol("foo");
// 给obj 添加了一个键名为 c, foo 变量值
Object.defineProperty(obj, "c", {
value: "3",
enumerable: false // 定义是否可枚举,默认 false
})
Object.defineProperty(obj, "d", {
value: "4",
enumerable: true // 定义是否可枚举
})
Object.defineProperty(obj, foo, {
value: "foobar",
enumerable: false
});
console.log("Object.keys(obj): ", Object.keys(obj)); // ["a", "b", "d"]
console.log("Object.getOwnPropertyNames(obj): ", Object.getOwnPropertyNames(obj)); // ["a", "b", "c", "d"]
console.log("Relfect.ownKeys(obj): ", Reflect.ownKeys(obj)); // [Symbol(foo)]
这部分的内容,看我之间的博客盒子水平垂直居中的方法,这部分的内容在该文章的最后,盒子居中章节。
之间的文章里有,深拷贝