去年面了一次字节, 答得比较菜, 挂了; 前两天接到了字节 hr 的电话, 问我的情况, 我说我刚入职了某个厂子, 他说没关系, 也可以试试嘛, 我想也对, 就接受了视频面试。
面试自我介绍不必说, 面试官问我, 你这刚入职怎么就想跳槽呢? 我可能太耿直了, 说其实是你们 hr 联系我的...
然后面试官给我的感觉就是, 整个面试过程特别急切, 当然我也比较菜, 一问三不知...
我说我 typescript 和 react 和 webpack 比较熟悉, 所以问题如下:
typescript 中 string 和 String 的区别
react hooks vs class, 为什么官方推荐用 hooks
浏览器缓存
介绍 https
react 事件代理
15 分钟实现一个 EventEmit
整个面试过程持续 41 分钟, 挂断后 5 分钟告诉我挂了... 总的来说, 个人比较菜, 算一次不怎么愉快的面试吧.
interface Handler {
  name: string;
  callback: Function;
  /**
   * 默认 false
   */
  isOnce?: boolean;
  /**
   * 默认 false
   */
  disabled?: boolean;
}
class Event {
  listeners: Handler[] = []
  
  on(name, callback) {
    this.listeners.push({
      name,
      callback,
    })
    return this
  }
  
  off(name, callback) {
    if (callback) {
      this.listeners = this.listeners.filter((item) => (
        (item.name !== name)
        || (item.callback !== callback)
       ))
      return this
    }
    this.listeners = this.listeners.filter((item) => (item.name !== name))
  }
  
  once(name, callback) {
    this.listeners.push({
      name,
      callback,
      isOnce: true,
    })
    return this
  }
  
  emit(name, value) {
    const listeners = this.listeners.filter((item) => (item.name === name) && (!item.disabled))
    for (let i = 0, len = listeners.length; i < len; i += 1) {
      const listener = listeners[i]
      listener.callback(value)
      if (listener.isOnce) {
        listener.disabled = true
      }
    }
  }
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.