首页 > 字节前端面经一二面---8.10
头像
世昕
编辑于 2020-08-11 10:14
+ 关注

字节前端面经一二面---8.10

一面

1. 下面的输出

   var a = {
     name: 'bytedance',
     func: function() {
       console.log(this.name);
     }
   };

   Var fun1 = a.func;
   fun1();

2. 一秒后输出1,两秒后输出4,三秒后输出5...

   let a = [1, 4, 5, 7, 9]
   // 1s
   1
   // 2s
   4
   // 3s
   5

3. display都有哪些属性?
inline、inline-block、block的区别?像是margin、padding和宽高都是哪些可以设置?

4.
注意1.45版本大于1.5。因为45版肯定大于第五版。
图片说明

5. 数据类型都有哪些?Symbol怎么创建的?

6. vue的v-if和v-for

7. 回答下闭包吧,你对闭包的理解

第一轮还有几题,我给忘了,想起来再补。

第二轮

1. 封装个简单版的axios();

2. 封装个可以检测所有数据类型的函数

   //我答的
   function testType(type){
       if(typeof type !='object'){
           return type;
       }
       if(type===null) return null;
       let str =  Object.prototype.toString.call(type);
       return str.slice(8,str.length-1);
   }
   console.log(testType({}));

3. 下面的输出

   log(1);
   setTimeout(()=>{log(2)}, 0);
   Promise.resolve().then(()=>{log(3)})
   var p = new Promise(res=>{
       log(4)
       setTimeout(()=>{
           res(5)
           log(6)
       },0)
   })
   p.then(e=>{log(e)})

4. 说一下原型链?
原型链继承的弊端?
怎么避免?

   我答了用Object.create(),这样可以复制一个原型链,不影响原本的父链。
   又问还有其他方法嘛?
   我说ES6继承
   ES6继承会不会影响父链?
   我答:不会,ES6继承源码就是用Object.create()实现的。

5. 数组扁平化输入:
[1,2,[3,4,[5,{a:1},[6]]]]

输出:[1,2,3,4,5,{a:1},6]

   function flat(arr){
       arr = JSON.stringify(arr).replace(/\[|\]/g,'');
       arr = '['+arr+']';
       return JSON.parse(arr);
   }
   console.log(flat([1,2,[3,4,[5,{a:1},[6]]]]));
   function flat(arr){
       if(typeof arr !='object') return arr;
       if(Object.prototype.toString.call(arr)=='[object Object]'){
           console.log(arr);
           return arr
       } 
       let res=[];
       for(let i=0;i<arr.length;i++){
           res[i] = flat(arr[i]);
       }
       return res;
   }
   console.log(flat([1,2,[3,4,[5,{a:1},[6]]]]));

6. tcp建立的过程?

讲了三次握手
为什么要三次握手呢?
两次握手不也可以建立链接嘛?
提示:tcp是全双工的通信

讲讲你对udp的理解?

7. 你都知道哪些http状态码?
200、301、304、307、403、404、500、503

更多模拟面试

全部评论

(7) 回帖
加载中...
话题 回帖

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐