说一下promise
箭头函数和普通函数的区别 能不能作为构造函数
- 箭头函数是铺通函数的简写,可以更优雅的定义一个函数,和普通函数相比,有以下几点差异
1.
闭包的含义 有哪些应用
手写一个防抖
call,apply,bind都有什么区别
let object = { a: 0 }
function fun(obj) {
obj.a = 1
obj = { a: 2 }
obj.b = 2
}
fun(object)
console.log(object)
// {a:1}
console.log(1);
async function async1() {
console.log(2);
await console.log(3);
console.log(4);
}
setTimeout(() => {
console.log(5);
}, 0);
async1();
new Promise(function (resolve) {
console.log(6);
resolve();
}).then(function () {
console.log(7);
});
console.log(8);
var name = 'window';
var obj = {
name:'obj',
normal(){
return ()=>{
console.log(this.name)
}
},
arrow: ()=>{
return function(){
console.log(this.name)
}
}
}
var obj1 = {name:'obj1'}
obj.normal.call(obj1)()
obj.arrow.call(obj1)()
let x = 5;
function fn(x) {
return function (y) {
console.log(y + (++x));
};
}
let f = fn(6);
f(7);
console.log(x);