1、settimeout promise在事件上区别
setTimeout(function() {
console.log('宏任务setTimeout'); //先遇到setTimeout,将其回调函数注册后分发到宏任务Event Queue
//如果setTimeout设置时间,那它会先把函数放到宏任务Event Table,等时间到了再放入宏任务Event Queue里面
})
new Promise(function(resolve) {
console.log('微任务promise'); //new Promise函数立即执行
resolve(); //必须resolve执行才能执行then
}).then(function() {
console.log('微任务then'); //then函数分发到微任务Event Queue
})
console.log('主线程console');
//微任务promise
//主线程console
// 微任务then
//宏任务setTimeout
async function async1() {
console.log('async1 start')
await async2()
console.log('async1 end')
}
async function async2() {
console.log('async2')
}
async1()
console.log('script end')
// 等效于
async function async1() {
console.log('async1 start')
new Promise(function(resolve){
console.log('async2')
resolve()
}).then(function(){
console.log('async1 end')
})
}
async1()
console.log('script end')
2、react key作用
3、react router实现原理
4、react 优化 fiber
5、useMemo、useCallback区别
6、箭头函数的this
7、简单请求、复杂请求
8、webpack plugin/loader区别,常用的webpack插件有哪些
9、自适应方法,不用rem怎么实现自适应
10、css ,js动画实现
11、跨域,网关请求设置返回头
12、继承
13、AMD、 commonjs 与es6
define([]){
}
// 用于node端
module.export={
}
// es6
import a from ''
export m
//如要通过打包转换成内置require 去调用
CommonJS 模块输出的是一个值的拷贝,ES6 模块输出的是值的引用。
var a=requie()
CommonJS 模块是运行时加载,ES6 模块是编译时输出接口。
CommonJs 是单个值导出,ES6 Module可以导出多个
CommonJs 是动态语法可以写在判断里,ES6 Module 静态语法只能写在顶层
CommonJs 的 this 是当前模块,ES6 Module的 this 是 undefined