前端开发:头条三面-----凉

一面

1.实现duplicate()函数

var a = "123";
a.duplicate() // '123123"

答案

String.prototype.duplicate = function() {
    return this+this;    
}

2.this绑定问题,判断输出什么

window.name = 'ByteDance'; 
class A {
    constructor() {
      this.name = 123;
    }
    getA() { 
        console.log(this);
        return this.name + 1; 
    }
} 
let a = new A(); 
let funcA = a.getA;
funcA();
var length = 10;
function fn() {    
    alert(this.length) 
}
var obj = {
    length: 5,        
    method: function (fn) {
        fn()                    //10
        arguments[0]()  //1
    },
}
obj.method(fn);  

3.用正则表达式实现sprintf函数

const template = "My name is ${name},I'm from ${city}"; 
const result = sprintf(template, {
    name: 'Yiming Zhang',
    city: 'FuJian',
}); 
//result="My name is Yiming Zhang,I'm from FuJian"

答案:

const sprintf = (str, data) => ( Object.keys(data).reduce((prev, cur) => { let reg = new RegExp('\\$\\{' + cur + '\\}', 'g'); return prev.replace(reg, data[cur]);
    }, str);
);

4.设计一个函数,产生唯一的uuid
5.手写函数节流(不使用setTimeOut()和setInterval())

function throttle(wait, fn) {
    var prev_time = null;
    return function (){
            var now_time = new Date().getTime();
            if(!prev_time || now_time - prev_time>= wait) {
                prev_time = now_time;
                fn().apply(null, arguments); 
            }
    }
}

6.拥塞控制阶段
7.position的sticky属性
8.OSI七层模型

二面

1.mysql线程池
2.node如何启动多个进程
3.进线程通信
4.pm2启动运行多少个线程
5.rpc和http区别
6.koa如何写中间件
7.实现Promise.race( )函数
8.rpc是什么,rpc和http的区别

三面

1.实现倒计时
2.项目亮点(头条挂在了这里,哭)
3.双向绑定

结尾

二面和三面其实还问了一些东西,但是想不起来了。

#字节跳动##面经##校招##前端工程师#
全部评论
一面看来内容不少其他感觉问的不多
1 回复
分享
发布于 2019-08-20 00:02
当时有笔试嘛
点赞 回复
分享
发布于 2019-08-19 21:08
联想
校招火热招聘中
官网直投
面的是什么岗呀
点赞 回复
分享
发布于 2019-08-20 00:12
你今天收到的拒信吗?...一面的代码题比我多好多
点赞 回复
分享
发布于 2019-08-21 18:59
本科?
点赞 回复
分享
发布于 2019-09-22 23:41
二面怎么看起来不太像前端的面试。。
点赞 回复
分享
发布于 2019-10-13 16:15

相关推荐

1 29 评论
分享
牛客网
牛客企业服务