zoukankan      html  css  js  c++  java
  • Weak Set

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
    </head>
    <body>
      <script>
        let set = new WeakSet()
        let key = {}
    
        set.add(key)
        console.log(set.has(key))  //true
    
        key = { a: 1 }   //移除了key的第一个引用,添加了新的引用
        console.log(set.has(key))  //false, Weak Set中的引用也自动移除
      </script>
    </body>
    </html>
  • 相关阅读:
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    8.React 组件封装
    window.location / history / 以及相关事件
  • 原文地址:https://www.cnblogs.com/xutongbao/p/14876283.html
Copyright © 2011-2022 走看看