有幻想,有干货,微信搜寻 【大迁世界】 关注这个在凌晨还在刷碗的刷碗智。

本文 GitHub https://github.com/qq449245884/xiaozhi 已收录,有一线大厂面试残缺考点、材料以及我的系列文章。

最近,换了工作,加入了n次面试。过程绝对欢快的经验。然而,有一些问题的十分辣手,比方上面这些。

1.意外的全局变量

function crazyFunction() {  var a = (b = 10);}crazyFunction();console.log("b", typeof b === "undefined");console.log("a", typeof a === "undefined");

2. 视力测试

const numbers = [1, 2, 3];for (var index = 0; index < numbers.length; index++);{  const number = numbers[index];  console.log(number);}

3. 辣手的闭合

let i;for (i = 0; i < 3; i++) {  const log = () => {    console.log(i);  };  setTimeout(log, 100);}

我1 2 题目全错,只答对了第3题目,哭。。。

你有答案了吧,上面揭晓。

1. b false   a true2. undefined3. 3   3   3

我第一题目的答案是

b  truea  false

刚好相同,完满错过。

我第二题答复的是

123

大家有没有发现问题所在,没错就是

for (var index = 0; index < numbers.length; index++); // 这里多了分号,真是考查目力呀

大家对答案有想法的,能够留言分享,咱们一起学习。

编辑中可能存在的bug没法实时晓得,预先为了解决这些bug,花了大量的工夫进行log 调试,这边顺便给大家举荐一个好用的BUG监控工具 Fundebug。

交换

有幻想,有干货,微信搜寻 【大迁世界】 关注这个在凌晨还在刷碗的刷碗智。

本文 GitHub https://github.com/qq449245884/xiaozhi 已收录,有一线大厂面试残缺考点、材料以及我的系列文章。