React 深度學習:番外一

  1. 隨機字符串dom

    const randomKey = Math.random()
      .toString(36)
      .slice(2);
    複製代碼
    • Math.random:返回一個浮點僞隨機數,範圍[0,1)
    • numObj.toString([radix]):使用 radix 做爲基數將數字轉爲字符串,默認 10,radix 取值爲 2-36,會使用。
    • 通過前兩步以後,會獲得 0.dq8ph5rrq6s 的字符串,所以須要將前兩位截去
  2. 得到 undefinedui

    let test = void 0;
    複製代碼

    void 運算符對給定的表達式進行求值,而後返回 undefinedspa

相關文章
相關標籤/搜索