JS 日常技巧

JS 生成唯一ID


  /**
   * generate an unique id string (32)
   * @private
   * @return string
   */
  getUniqueID() {
    let id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        let r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
    return id;
  }

JS HOOK console

const method = ['log', 'info', 'warn', 'debug', 'error'];
window.console[method] = (...args) => {};

 

你可能感兴趣的:(前端)