字节跳动_中国交易与广告前端面经
字节跳动_中国交易与广告(上海)
面试时间
2026_0512-19:00
面试内容
- 自我介绍
- DataAgent 的项目是怎么样的?能介绍一下吗?
- 大概说一下这个项目的前端内容有哪些呢?
- 这个项目中你主要负责什么?
- AI 返回的 ECharts 图表有考虑过万一 AI 报错了怎么办呢?
- 第二个项目中,你有遇到什么难题,挑几个说一下吧。
- 看你之前写了一个 MCP 服务器,能详细解释一下这个吗?
- Agent 相关的了解吗?可以讲一下吗?
- 你对 Skill 的理解是什么?
- 能讲一下你怎么理解 RAG 吗?
- 你提到最新的框架都有 llms.txt,面试官和我讲了一下 IDE 里面 RAG 和搜索的两种方式。
- JS 基本数据类型
- 开发中引用类型和基本数据类型有什么要注意的点吗?
- Vue 和 React 都了解吗?
- 可变数据和不可变数据有了解吗?
- React 中更改数据需要返回的 set 方法去更改,那引用类型有什么需要注意的吗?
- 代码性能问题分析:
javascript
function parseLines(files) {
return String(files).split("\n");
}
function renderLinesSlow(files, container) {
const text = parseLines(files); // 几十万行的文本
for (const line of text) {
const dom = document.createElement("p");
dom.textContent = line;
container.append(dom);
}
}
- 问题:频繁
append+ 一次性渲染过多节点,主线程阻塞、页面卡顿。 - 优化:虚拟滚动、分片渲染(
requestIdleCallback/setTimeout)、DocumentFragment批量插入。
- 手撕代码:异步并发调度器(实现一个
Scheduler类,控制异步任务并发数量)
javascript
class Scheduler {
constructor(limit) {
this.limit = limit; // 最大并发数
this.running = 0; // 当前运行中的任务数
this.queue = []; // 等待队列
}
// 添加任务:接收一个返回 Promise 的函数
add(task) {
return new Promise((resolve, reject) => {
this.queue.push({ task, resolve, reject });
this._run();
});
}
_run() {
while (this.running < this.limit && this.queue.length) {
const { task, resolve, reject } = this.queue.shift();
this.running++;
task()
.then(resolve)
.catch(reject)
.finally(() => {
this.running--;
this._run();
});
}
}
}
// 使用示例
const scheduler = new Scheduler(2);
const timeout = (ms, value) =>
new Promise((resolve) => setTimeout(() => resolve(value), ms));
scheduler.add(() => timeout(1000, "A")).then(console.log);
scheduler.add(() => timeout(500, "B")).then(console.log);
scheduler.add(() => timeout(300, "C")).then(console.log);
scheduler.add(() => timeout(400, "D")).then(console.log);
// 输出顺序:B, C, A, D (并发数为2,按完成时间输出)