字节跳动春招面经(武汉前端全职,终于拿到 offer...)
## 一面 (1 h)
1. 盒模型说一下
2. html里面的meta标签有哪些
3. 基本类型有哪些,symbol()
4. Byte-dance-fe => byteDanceFe 转化为驼峰写法
5. 浏览器中的缓存有哪些
6. http 状态码有哪些
7. 跨域是什么,怎么解决跨域问题
8. fetch 请求怎么发
9. 重排和重绘是什么
10. 创建DOM节点,添加,删除,替换,克隆对应的 api 是什么
11. css 动画怎么实现,有哪几种方法
12. Promise 是什么,Promise.all() 和 Promise.race() 怎么用,举个例子
13. 实现一个 Event 类,具有 on\off\trigger\once 四个方法
14. 实现去抖函数
```js
function debounce (fn, dely) {
// TODO
};
function console1 () {
console.log(1);
}
const a = debounce(console, 1000);
a()
a()
a()
//////////////////////
1 // just once
```
15. 判断输出顺序
```js
console.log('begin');
setTimeout(() => {
console.log('setTimeout 1');
Promise.resolve().then(() => {
console.log('promise 1');
setTimeout(() => {
console.log('setTimeout2');
})
}).then(() => {
console.log('promise 2');
});
}, 0);
console.log('end');
```
## 二面 (1 h)
1. 一些基础的前端概念,记不清了
2. 判断输出
```js
var a = 10;
function b() {
a = 1;
return;
function a() {}
}
b();
console.log(a);
```
3. 写一个 DOM2JSON(node) 函数,node 有 tagName 和 childNodes 属性,示例:
```html
<div>
<span>
<a></a>
</span>
<span>
<a></a>
<a></a>
</span>
</div>
```
```json
{
tag: 'DIV',
children: [{
tag: 'SPAN',
children: [
{ tag: 'A', children: [] }
]
},
{
tag: 'SPAN',
children: [
{ tag: 'A', children: [] },
{ tag: 'A', children: [] }
]
}]
}
```
4. 实现反转函数
```js
class Node {
constructor(value, next) {
this.value = value;
this.next = next;
}
}
function reverseList(node) {
// TODO
}
reverseList(head)
```
5. 解释并实现 new 操作 `function newOperator(Constructor, args) {}`
6. 判断输出顺序
```html
<div id="div">
<button id="button">button</button>
</div>
<script>
document.getElementById('div').addEventListener('click', function(e) {
console.log('1')
}, false)
document.getElementById('div').addEventListener('click', function(e) {
console.log('2')
}, true)
document.getElementById('button').addEventListener('click', function(e) {
console.log('button')
}, false)
</script>
```
## 三面 (1 h)
1. 实现函数,输入为一个数组,输出为一个数组。具体:手里有副洗乱的牌,进行如下操作,第一张放在桌子上,第二张插入牌底,第三张放在桌子上,第四张插入牌底..... 现已知桌子上牌的顺序,求原来手里牌的顺序
2. 面试官出了一道数据处理的题,需要口述实现方法,并解释复杂度
3. 不用 js,怎么实现登录验证(从登录页面进入个人主页)
4. cookie 和 session 是什么
5. 你的优势是什么