字节跳动 2021前端春招补录 一面

  1. 自我介绍

  2. 问是否有做过算法方面的项目:
    之前只写过一个迷你编译器的前端,简单的介绍了一下

  3. 问css

    • css选择器优先级问题

      .lightblue p{
        color: lightblue;    // 浅蓝
      }
      .darkblue p{
        color: darkblue;    // 深蓝
      }
      <div class="lightblue">
        <div class="darkblue">
            <p>我是什么颜色?</p>
        </div>
      </div>
      
      <div class="darkblue">
        <div class="lightblue">
            <p>我是什么颜色?</p>
        </div>
      </div>
    • CSS 盒子模型,从外到内的属性?

  4. http问题

    • 常见的状态码
    • 状态码304表示什么
    • 了解http缓存吗
    • tcp和udp的区别
  5. js问题

    • 描述一下原型链
    • 做一道js的题,分别输出什么
      var a= function () { this.b =3; }
      var c = new a();
      a.protorype.b = 9;
      var b = 7;
      a();
      console.log(b);
      console.log(c.b);
    • 箭头函数语法问题
      var func1 = x => x;
      var func2 = x => {x};
      var func3 = x => ({x});
      console.log(func1(1));
      console.log(func2(1));
      console.log(func3(1));
    • 谈谈let,const,var的区别
    • js异步问题
      1)代码补充asyncGetValue()
      function asyncAdd(a, b, callback) {
      doAsyncWork(a, b).then(value => callback(value));
      }
      function asyncGetValue(a, b) {
      .....
      }
      使之能够实现
      asyncGetValue(1,2).then(v => console.log(v));
      2) 如果是实现asyncGetValues(list),list是一个对象数组,类似于
      const list = [
      {a: 1, b: 2},
      {a: 100, b: 200},
      {a: 11, b: 21},
      {a: 31, b: 41},
      {a: 41, b: 51}];
      function asyncGetValues(list) {
      .....
      }
      3)在第三问的基础上实现并发控制,即有一个最大的并发数maxConcurreent

更新:

  1. 两个都输出是3
  2. 箭头语法题目,分别输出
    1
    undefined
    {x:1}
  3. 异步代码实现
    1)
    function asyncGetValue(a,b){
     return new Promise(res=>{
     asyncAdd(a,b,res)
    })
    }
    2)使用了Promise.all()
    return Promise.all(list.map(x=>{return new Promise(
    res=>asyncAdd(x.a,x.b,res)
    )}))
    3)递归,经典的字节面试题,答案可能有些bug

    更新,本菜鸡写的代码有bug,并发控制题可以参考这篇文章js实现并发控制

    return new Promise((res)=>{
     let cnt=0;
     let length=list.length;
     let ansList=Array(length).fill(false);
     while(cnt<Math.min(length,maxConcurrent)) next();
     const next=()=>{
         let current=cnt++;
         let currentObj=list[current];
         addAsync(currentObj.a,currentObj.b,(value)=>{
             ansList[current]=value;
              if(cnt<length) next();
         })
        if(cnt>=length&&ansList.filter(x=>x===false).length===0) res(ansList) 
     }
    })
#字节跳动前端面经##面经##校招##字节跳动##前端工程师#
全部评论
一面没过,面试官说我css部分和网络部分不大好( ;∀;),字节真的比较重基础了,面试前一直在准备项目相关,但是没有问
1 回复
分享
发布于 2021-03-02 00:01
楼主是什么部门?base哪里的?
点赞 回复
分享
发布于 2021-03-01 17:26
联想
校招火热招聘中
官网直投
大佬js 异步问题是怎么写的 题目我都看不懂。。
点赞 回复
分享
发布于 2021-03-01 17:56
doAsyncWork 这个函数没有用到吗? 或者在哪定义了? 还是题不全
点赞 回复
分享
发布于 2021-03-01 21:27
有答案吗
点赞 回复
分享
发布于 2021-03-01 23:17
不愧是宇宙条,大佬们都是宇宙人
点赞 回复
分享
发布于 2021-03-02 02:23
春招补录有笔试码?
点赞 回复
分享
发布于 2021-03-02 09:13
请问第五题这里console.log(b);为啥输出3呀, 为啥不是7,7不是在a之后被赋值的吗 var a= function () { this.b =3; } var c = new a(); a.protorype.b = 9; var b = 7; a(); console.log(b); console.log(c.b);
点赞 回复
分享
发布于 2021-03-02 15:38

相关推荐

4 62 评论
分享
牛客网
牛客企业服务