当前位置: 首页 > 面试经验 >

每平每屋(23届秋招)前端笔经

优质
小牛编辑
79浏览
2023-03-28

每平每屋(23届秋招)前端笔经

9.24 19:30 笔试


开始进军中小公司了
这个笔试的体验不错,难度中等,形势很独特,没有什么后端的选择题啥的,也都不能查到答案,应该是自创的题目
感觉像一次微面试吧,记录一下


平台:ShouMeBug;时间:120min;总分:100分
题型:简答题10分+10分;编程题15分+20分+20分+25分

一、简答题
题1(10分)、this指向问题
//testFunc为普通函数
var testFunc = function(){
  console.log(this)
}
//testFunc为箭头函数
var testFunc = ()=>{
  console.log(this)
}

var objA = { testFunc: testFunc }
var objB={}
var testFuncBind = testFunc.bind(objA)
var ttFun = objA.testFunc

//testFunc为箭头函数和普通函数的情况下,以下代码分别输出什么?
testFunc()
objA.testFunc()
testFuncBind()
testFunc.apply(objA)
testFuncBind.apply(objB)
ttFun()
//简要解释一下你的答案
箭头函数:window window window window window window
普通函数:window testFunc testFunc testFunc testFunc window

题2(10分)、以下代码的输出结果是?请作出简要解释。
setTimeout(function(){
  const p = new Promise(function (r,j){
    console.log(1)
    r()
  })
  p.then(()=>{
    console.log(2)
  })
  console.log(3)
},1000)
const np =new Promise((r,j)=>{
  console.log(5)
  r()
}).then(()=>{
  setTimeout(function(){
    console.log(6)
  },0)
  return 7
}).then(n=>{
  console.log(n)
})
console.log(4)
5 4 7 6 1 3 2

二、编程题
题3(15分):请编写代码将源数据转为目标数据格式
源数据:
[
    { id: 1, name: 'group1', parentId:0 },
    { id: 2, name: 'group2', parentId:1 },
    { id: 3, name: 'group3', parentId:1 },
    { id: 4, name: 'group4', parentId:2 },
    { id: 5, name: 'group5', parentId:4 }
]
目标数据:
[
	{
		"id": 1,
		"name": "group1",
		"parentId": 0,
		"children": [
			{
				"id": 2,
				"name": "group2",
				"parentId": 1,
				"children": [
					{
						"id":
题4(20分): 在服务器上有两个json文件,需要同时请求两个json,将key不同的项提取出来组成一个新的json,要求不使用Promise.all,可以使用fetch
 类似资料: