2020春招,字节前端二面面试
1.有序数组合并
let a = [1,3,5];
let b = [2,4,6,7];
merge(a,b)
// [1,2,3,4,5,6,7]
2.二叉树:
........... a
........../.....\
........b........c
....../....\
....d........e
.....\ ...../
........../.....\
........b........c
....../....\
....d........e
.....\ ...../
......f....g
中序遍历 结果
3.原型链继承实现
4.js如何获取页面dom
5.
function A() {
this.name = '123';
}
A.prototype.getA = function () {
console.log(this);
return this.name + 1;
}
let a = new A();
let funcA = a.getA;
#字节跳动##前端工程师##校招##面经#
for (var i = 0; i < 5; i++) {
setTimeout(function () {
console.log(i);
}, 5);
}
6.window.name = 'bytedance';function A() {
this.name = '123';
}
A.prototype.getA = function () {
console.log(this);
return this.name + 1;
}
let a = new A();
let funcA = a.getA;
funcA()
a.getA()
7.
- 给定一个字符串如下,请统计字符串中出现最多的字母和次数
function findMaxDuplicateChar(str) {
let maxChar = ''
let maxValue = 1
// 补全代码.....
return {
maxChar,
maxValue
};
}
const str = 'this is a fe test at toutiao on September'
findMaxDuplicateChar(str) // output: { maxChar: "t", maxValue:7 }