1. 如何理解MVVM原理?
call 和 apply区别与性能
3. 虚拟dom操作比原生dom快吗
4. 为什么不建议子组件修改props5. setTimeout与异步任务的执行打印结果问题
如下一段代码打印结果如何? ```javascript console.log(‘global’)
setTimeout(function () { console.log(‘timeout1’) new Promise(function (resolve) { console.log(‘timeout1_promise’) resolve() }).then(function () { console.log(‘timeout1_then’) }) },2000)
for (var i = 1;i <= 5;i ++) { setTimeout(function() { console.log(i) },i*1000) console.log(i) }
new Promise(function (resolve) { console.log(‘promise1’) resolve() }).then(function () { console.log(‘then1’) })
setTimeout(function () { console.log(‘timeout2’) new Promise(function (resolve) { console.log(‘timeout2_promise’) resolve() }).then(function () { console.log(‘timeout2_then’) }) }, 1000)
new Promise(function (resolve) { console.log(‘promise2’) resolve() }).then(function () { console.log(‘then2’) })
// 答案 global 1 2 3 4 5 promise1 promise2 then1 then2 6 timeout2 timeout2_promise timeout2_then timeout1 timeout1_promise timeout1_then 6 6 6 6
参考:[彻底理解setTimeout()](https://www.jianshu.com/p/3e482748369d?from=groupmessage)
2. 下面代码执行顺序
```javascript
setTimeout(function(){
console.log('定时器开始啦')
});
new Promise(function(resolve){
console.log('马上执行for循环啦');
for(var i = 0; i < 10000; i++){
i == 99 && resolve();
}
}).then(function(){
console.log('执行then函数啦')
});
console.log('代码执行结束');
// 答案
// 马上执行for循环啦
// 代码执行结束
// 执行then函数啦
// 定时器开始啦
6. 关于javaScript运行逻辑
虚拟dom的比较原则
dom加key的作用是啥
for循环性能为什么高于foreach