- 时间传播的三个阶段是什么
捕获-目标-冒泡
- 所有对象都有原型 (错误)
原因:除了基础对象外
- 对象相等都是false({name:‘aa’}=={name:‘aa’}//false)
- 代码示例
function getAge(...args) {
console.log(args);//[21]
}
getAge(21);
- 下面代码的输出是什么?
const a = {};
const b = { key: "b" };
const c = { key: "c" };
a[b] = 123;
a[c] = 456;
console.log(a[b]);//456
//对象键自动转换为字符串[Object object]。
- 一段代码
new Boolean(false); //true
- 下面代码的输出是什么
[[0, 1], [2, 3]].reduce(
(acc, cur) => {
return acc.concat(cur);
},
[1, 2]
);
// [1, 2, 0, 1, 2, 3]
// 这里注意的是第二个参数是默认值,等于函数里面的第一个参数acc
- 下面代码的输出是什么?
import myCounter from "./counter";
myCounter++;
console.log("===========",myCounter) //error read-only
- const 定义的全局变量不能被删除
- import会在编译阶段执行,也就是会前置,在import前的代码也会在它后面执行
- 下面代码的输出是什么?
// String.raw 会返回原始字符串,忽略转移字符
console.log("===========",String.raw`hello\hofff`)
评论
使用 GitHub 账号登录后即可评论