一行代码系列

  1. url query
    Object.fromEntries(new URLSearchParams(window.location.search))
    
    Object.fromEntries()  : transforms a list of key-value pairs into an object.
  2. ~~ 代替 parseInt
    ~~1.2 // 1
    ~~1.8 // 1
    
    ~~false // 0
    ~~true // 1
    
    
  3. deep clone
    const obj  = {
      title: "xxx",
      date: new Date(),
      attendees: ["xxxxxxx"]
    }
    
    const copied = structuredClone(obj)
    
posted @ 2022-11-17 20:55  扫眉  阅读(12)  评论(0)    收藏  举报