猿辅导前端一面

挂了,两道题都没做上来。

上来介绍了一下项目,然后是项目里用到了 cookie,就问还有哪些方式可以存,说了 localstorage,然后又问 localstorage 和 sessionstorage 的区别。

然后给了一个 classA

function ClassA()
{ 
    this.name = 'classA' 
} 
const classA = new ClassA () 
ClassA.prototype =
classA.__proto__ = 
classA instanceof ClassA 
true
false
  • new 出来的实例 this 指向哪
  • 怎么修改 new 出来的 this 的指向(当时说的 new 出来的指向不能修改)
  • 换了个问法,怎么在构造函数中修改 this 的指向。说了个借用构造函数也没说对不对
  • ClassA 的 prototype 是啥,有啥
  • classA 的 proto 是啥
  • 原型链讲一下
  • instanceof 什么时候返回 true,什么时候返回 false
  • 怎么让 classA instanceof ClassA 返回 false
  • js 里面异步的方式有哪些
// 写一个 cb2promise 函数,参数是一个函数,将 getUrl 转换成 getUrlPromise
// callback (error, data)
function getUrl(callback)
function getUrlPromise(){}
function cb2promise(fn)
const getUrlPromise = cb2promise(getUrl);
getUrlPromise.then(data=>{}).catch(err=>{})
// 写一个函数,将传进去的数组按深度展开
list:[1,2,[3,4],[5,6,[7,8],9],10,11]
// depth 等于 1 时输出
depth = 1 :[1,2,3,4,5,6,[7,8],9,10,11]
// depth 等于 2 时输出
depth = 2 :[1,2,3,4,5,6,7,8,9,10,11]
function flattern(list,depth){
}
  • 对框架有了解吗,对 css3 有了解吗,移动端适配讲了一下。平时除了看书还有哪些学习途径

应该凉了,毕竟两道题都没做出来

#猿辅导##前端工程师##面经##秋招##内推#
全部评论
 function flattern(list,depth=0){                 var res = [];                 for(var item of list){                     if(Array.isArray(item) && depth>0){                         //深度                         var child = flattern(item,depth-1);                         res = res.concat(child)                     }else{                         res.push(item);                     }                 }                 return res;             } 刚刚做了一下第二个,是这个意思吗
点赞 回复
分享
发布于 2018-08-23 14:09
楼主加油~
点赞 回复
分享
发布于 2018-08-23 14:09
阿里巴巴
校招火热招聘中
官网直投
感谢楼主分享 一起加油
点赞 回复
分享
发布于 2018-08-23 14:11
function flattern(list,depth){ var array = []; list.forEach(ele=>{ if( depth !== 0 && ele.constructor === Array){ array.push(...(flattern(ele,depth-1))); }else if(ele.constructor!==Array){ array.push(ele) }else{ array.push(ele) } }); return array; } 这是我面完以后第二题的思路,不过感觉上面的更简单,大家可以参考他的
点赞 回复
分享
发布于 2018-08-23 14:55
是电话面试吗
点赞 回复
分享
发布于 2018-08-23 16:46
666
点赞 回复
分享
发布于 2018-08-23 18:12
咋知道自己挂没挂
点赞 回复
分享
发布于 2018-08-24 10:05
我刚刚也是前端一面 面试官上来就是写一个promise吧 一共有三个编程 两个都是promise  我第一个就没有怎么写出来 他后面还给我promise 真的是 唉。另一个是数组相关 那个我应该做出来了 应该挂了
点赞 回复
分享
发布于 2018-08-24 11:40
new 出来的指向不能修改,可以修改吗
点赞 回复
分享
发布于 2018-08-24 14:22
想问楼主是参加过笔试之后约的面试吗
点赞 回复
分享
发布于 2018-08-25 16:18
var newArr=[]; function flattern(list,depth){   list.forEach(item=>(     depth === 0 ? newArr.push(item) :      typeof item==='object' ? flattern(item,depth-1) : newArr.push(item)   ))   return newArr; }
点赞 回复
分享
发布于 2018-08-31 12:01
我也来凑个热闹,自己是小白一个,借鉴了上面各位的答案,自己试着用递归也写了一个,递归我还得多多理解,迄今为止各大公司的在线笔试还没过过,就问:还有谁 var list=[1,2,[3,4],[5,6,[7,8],9],10,11]; function ditui(list,deepth){     var arr=[];     for(var item of list){         if(Array.isArray(item)===false||deepth===0){         arr.push(item);         }         else{             arr.push(...ditui(item,deepth-1));         }     }     return arr; } ditui(list,1);
点赞 回复
分享
发布于 2018-08-31 15:23
 写一个 cb2promise 函数,参数是一个函数,将 getUrl 转换成 getUrlPromise 这个什么意思?
点赞 回复
分享
发布于 2018-08-31 15:31

相关推荐

点赞 评论 收藏
转发
4 73 评论
分享
牛客网
牛客企业服务