Repository: Advanced-Frontend/Daily-Interview-Question
Branch: master
Commit: 46a268536dc0
Files: 5
Total size: 90.6 KB
Directory structure:
gitextract_2doicp7v/
├── .gitattributes
├── .gitignore
├── README.md
└── datum/
├── summary-english.md
└── summary.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.md linguist-language=JavaScript
*.js linguist-language=JavaScript
*.css linguist-language=JavaScript
*.html linguist-language=JavaScript
================================================
FILE: .gitignore
================================================
.DS_Store
================================================
FILE: README.md
================================================
# Daily-Interview-Question
加入「前端面试互助群」学习小组,搜索公众号「高级前端进阶」,关注即可加入!
工作日每天一道大厂前端面试题,一年后再回头,会感谢曾经努力的自己!
[线上版本阅读更流畅,点击阅读](https://muyiy.cn/question/)
[推荐一个不错的前端算法系列,点击查看](https://github.com/sisterAn/JavaScript-Algorithms)
推荐扫码使用微信小程序,除了本项目之外,还囊括了算法题、选择题等多种类型题目和详细解析
记住我们的 Slogan:上下班路上刷一点,半年突击进大厂
## 今日面试题
第 162 题:实现对象的 Map 函数类似 Array.prototype.map
解析:[第 162 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/431)
## 最近汇总
第 161 题:用最精炼的代码实现数组非零非负最小值 index
```js
// 例如:[10,21,0,-7,35,7,9,23,18] 输出 5, 7 最小
function getIndex(arr){
let index=null;
...
return index;
}
```
解析:[第 161 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/421)
第 160 题:输出以下代码运行结果,为什么?如果希望每隔 1s 输出一个结果,应该如何改造?注意不可改动 square 方法
```js
const list = [1, 2, 3]
const square = num => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(num * num)
}, 1000)
})
}
function test() {
list.forEach(async x=> {
const res = await square(x)
console.log(res)
})
}
test()
```
解析:[第 160 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/389)
第 159 题:实现 `Promise.retry`,成功后 `resolve` 结果,失败后重试,尝试超过一定次数才真正的 `reject`
解析:[第 159 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/387)
第 158 题:如何模拟实现 Array.prototype.splice
解析:[第 158 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/384)
第 157 题:浏览器缓存 ETag 里的值是怎么生成的
解析:[第 157 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/383)
第 156 题:求最终 left、right 的宽度
```js
```
注:此题和 155 题 left、right 样式有些不同
解析:[第 156 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/382)
第 155 题:求最终 left、right 的宽度
```js
```
解析:[第 155 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/381)
第 154 题:弹性盒子中 flex: 0 1 auto 表示什么意思
解析:[第 154 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/380)
第 153 题:实现一个批量请求函数 multiRequest(urls, maxNum)
要求如下:
1. 要求最大并发数 maxNum
2. 每当有一个请求返回,就留下一个空位,可以增加新的请求
3. 所有请求完成后,结果按照 urls 里面的顺序依次打出
解析:[第 153 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/378)
2019-12-31
> 第 152 题:实现一个 normalize 函数,能将输入的特定的字符串转化为特定的结构化数据
解析:[第 152 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/331)
2019-11-25
> 第 151 题:用最简洁代码实现 indexOf 方法
>
解析:[第 151 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/321)
2019-11-21
> 第 150 题:二分查找如何定位左边界和右边界
>
> 不使用JS数组API,查找有序数列最先出现的位置和最后出现的位置
解析:[第 150 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/320)
2019-11-12
> 第 149 题:babel 怎么把字符串解析成 AST,是怎么进行词法/语法分析的?
解析:[第 149 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/315)
2019-11-01
> 第 148 题: webpack 中 loader 和 plugin 的区别是什么(平安)
解析:[第 148 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/308)
2019-10-31
> 第 147 题:v-if、v-show、v-html 的原理是什么,它是如何封装的?
解析:[第 147 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/307)
2019-10-29
> 第 146 题:Vue 中的 computed 和 watch 的区别在哪里(虾皮)
解析:[第 146 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/304)
2019-10-24
> 第 145 题:前端项目如何找出性能瓶颈(阿里)
解析:[第 145 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/300)
2019-10-22
> 第 144 题:手写二进制转 Base64(阿里)
解析:[第 144 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/299)
2019-10-21
> 第 143 题:将 '10000000000' 形式的字符串,以每 3 位进行分隔展示 '10.000.000.000'
解析:[第 143 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/296)
2019-10-17
> 第 142 题:(算法题)求多个数组之间的交集(阿里)
解析:[第 142 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/293)
2019-10-15
> 第 141 题:Vue 中的 computed 是如何实现的(腾讯、平安)
解析:[第 141 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/291)
2019-10-14
> 第 140 题:为什么 HTTP1.1 不能实现多路复用(腾讯)
解析:[第 140 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/290)
2019-09-17
> 第 139 题:谈一谈 nextTick 的原理
解析:[第 139 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/281)
2019-09-11
> 第 138 题:反转链表,每 k 个节点反转一次,不足 k 就保持原有顺序(哔哩哔哩)
解析:[第 138 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/278)
2019-09-04
> 第 137 题:如何在 H5 和小程序项目中计算白屏时间和首屏时间,说说你的思路
解析:[第 137 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/272)
## 所有面试题汇总
- [壹题所有题目及答案汇总](https://github.com/Advanced-Frontend/Daily-Interview-Question/blob/master/datum/summary.md)
## 半月刊
- [前端 100 问:能搞懂 80% 的请把简历给我](https://github.com/yygmind/blog/issues/43)
- [【半月刊 1】前端高频面试题及答案汇总](https://juejin.im/post/5c6977e46fb9a049fd1063dc)
- [【半月刊 2】前端高频面试题及答案汇总](https://juejin.im/post/5c7bd72ef265da2de80f7f17)
- [【半月刊 3】前端高频面试题及答案汇总](https://juejin.im/post/5c9ac3f66fb9a070e056718f)
- [【半月刊 4】前端高频面试题及答案汇总](https://juejin.im/post/5cb3376bf265da039c0543da)
## 联系我
进阶系列文章汇总如下,觉得不错点个 star,欢迎 **加群** 互相学习。
> [https://github.com/yygmind/blog](https://github.com/yygmind/blog)
我是木易杨,公众号「高级前端进阶」作者,跟着我**每周重点攻克一个前端面试重难点**。接下来让我带你走进高级前端的世界,在进阶的路上,共勉!

================================================
FILE: datum/summary-english.md
================================================
## Front-end interview questions and answers summary
### Question 1: Why do you write a key in a list of a component when writing a React / Vue project? What is the purpose?
Company: Drip, hungry?
Analysis: [Question 1](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/1)
### Question 2:`['1', '2', '3'].map(parseInt)` what & why ?
Analysis: [Question 2](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/4)
### Question 3:What is anti-shake and throttling? What's the difference? How to achieve?
Company: Digging for money
Analysis: [Question 3](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/5)
### Question 4:Introduce the difference between Set, Map, WeakSet and WeakMap?
Analysis: [Question 4](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/6)
### Question 5: Introducing depth-first traversal and breadth-first traversal, how to achieve it?
Analysis: [Question 5](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/9)
### Question 6:Do you implement a copy function with depth-first thinking and breadth-first thinking?
Analysis: [Question 6](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/10)
### Question 7:What is the difference between ES5/ES6 inheritance and writing?
Analysis: [Question 7](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/20)
### Question 8:The difference between setTimeout, Promise, Async/Await
Analysis: [Question 8](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/33)
### Question 9:How does Async/Await implement asynchronously by means of synchronization?
Company: headline, micro doctor
Analysis: [Question 9](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/156)
### Question 10:Asynchronous pen test questions
>Please write the result of the following code
```js
async function async1() {
console.log('async1 start');
await async2();
console.log('async1 end');
}
async function async2() {
console.log('async2');
}
console.log('script start');
setTimeout(function() {
console.log('setTimeout');
}, 0)
async1();
new Promise(function(resolve) {
console.log('promise1');
resolve();
}).then(function() {
console.log('promise2');
});
console.log('script end');
```
Analysis: [Question 10](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/7)
Company: Headline
### Question 11:Algorithm handwritten questions
>The following array is known:
>
> var arr = [ [1, 2, 2], [3, 4, 5, 5], [6, 7, 8, 9, [11, 12, [12, 13, [14] ] ] ], 10];
>
> Write a program to flatten the array and repeat some of the data, and finally get an ascending and non-repeating array
Company: Ctrip
Analysis: [Question 11](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/8)
### Question 12:The evolution and advantages and disadvantages of the JS asynchronous solution.
Company: Drip, Dig, Micro, Haikang
Analysis: [Question 12](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/11)
### Question 13:Is the Promise constructor executed synchronously or asynchronously, then what about the then method?
Company: Micromedical
Analysis: [Question 13](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/19)
### Question 14:Valentine's Day Welfare, how to implement a new
Company: Redeem
Analysis: [Question 14](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/12)
### Question 15:Briefly explain the multiplexing of http2
Company: Netease
Analysis: [Question 15](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/14)
### Question 16:Talk about your understanding of TCP three-way handshake and four wavers
Analysis: [Question 16](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/15)
### Question 17:After the A and B machines are connected normally, the B machine suddenly restarts and asks A what state is in TCP at this time.
>If A and B establish a normal connection, they never send data to each other. At this time, B suddenly restarts the machine and asks A what state is TCP at this time? How to eliminate this state in the server program? (Super-level questions, understand)
Analysis: [Question 17](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/21)
### Question 18:When is setState in React synchronous and when is it asynchronous?
Company: Micromedical
Analysis: [Question 18](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/17)
### Question 19: React setState pen test, what does the following code output?
```js
class Example extends React.Component {
constructor() {
super();
this.state = {
val: 0
};
}
componentDidMount() {
this.setState({val: this.state.val + 1});
console.log(this.state.val); // first log
this.setState({val: this.state.val + 1});
console.log(this.state.val); // 2nd log
setTimeout(() => {
this.setState({val: this.state.val + 1});
console.log(this.state.val); // 3rd log
this.setState({val: this.state.val + 1});
console.log(this.state.val); // 4th log
}, 0);
}
render() {
return null;
}
};
```
Analysis: [Question 19](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/18)
### Question 20: Introduce the npm module installation mechanism. Why can I automatically install the corresponding module by entering npm install?
Analysis: [Question 20](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/22)
### Question 21:There are three methods for judging arrays. Please introduce the differences and advantages between them.
> Object.prototype.toString.call() , instanceof , and Array.isArray()
Analysis: [Question 21](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/23)
### Question 22: Introducing Repaint & Reflow and how to optimize it
Analysis: [Question 22](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/24)
### Question 23: Introduce the difference between the observer mode and the subscription-release mode, and what scenarios are applicable to each
Analysis: [Question 23](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/25)
### Question 24:Talk about the design ideas of Redux and Vuex
Analysis: [Question 24](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/45)
### Question 25:Tell the difference between the browser and the Node event loop
Analysis: [Question 25](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/26)
### Question 26:Introducing the development of modularity
It can be considered from the perspectives of IIFE, AMD, CMD, CommonJS, UMD, webpack (require.ensure), ES Module,