If you have dreams and dry goods, you can search for [Great Move to the World] on WeChat and pay attention to this Shawanzhi who is still washing dishes in the early hours of the morning.
This article GitHub https://github.com/qq449245884/xiaozhi has been included, there are complete test sites, materials and my series of articles for interviews with first-line manufacturers.
Recently, I changed jobs and participated in n interviews. The process is relatively pleasant experience. However, there are some very tricky issues, such as the following.
1. Unexpected global variable
function crazyFunction() {
var a = (b = 10);
}
crazyFunction();
console.log("b", typeof b === "undefined");
console.log("a", typeof a === "undefined");
2. Vision test
const numbers = [1, 2, 3];
for (var index = 0; index < numbers.length; index++);{
const number = numbers[index];
console.log(number);
}
3. Tricky Closures
let i;
for (i = 0; i < 3; i++) {
const log = () => {
console.log(i);
};
setTimeout(log, 100);
}
My questions 1 and 2 were all wrong, and I only answered question 3 correctly, and I cried. . .
You have the answer, now it will be revealed.
1. b false
a true
2. undefined
3. 3
3
3
The answer to my first question is
b true
a false
On the contrary, a perfect miss.
My second answer is
1
2
3
Have you found the problem, that's right
for (var index = 0; index < numbers.length; index++); // 这里多了分号,真是考察眼力呀
If you have any ideas about the answer, you can leave a message and share, we will learn together.
The bugs that may exist in editing cannot be known in real time. In order to solve these bugs afterwards, a lot of time is spent on log debugging. By the way, here is a useful BUG monitoring tool , Fundebug .
comminicate
If you have dreams and dry goods, you can search for [Great Move to the World] on WeChat and pay attention to this Shawanzhi who is still washing dishes in the early hours of the morning.
This article GitHub https://github.com/qq449245884/xiaozhi has been included, there are complete test sites, materials and my series of articles for interviews with first-line manufacturers.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。