14_map.html 647 B

12345678910111213141516171819202122232425262728293031
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. var obj = {
  12. name:'zs'
  13. }
  14. var a1 = new Map()
  15. a1.set('age',20)
  16. // a1.set(obj,'aaa')
  17. a1.set('name','lisi')
  18. // console.log(a1)
  19. // console.log(a1.get('name'))
  20. // console.log(a1.get(obj))
  21. /* entries() key value 都拿出来 放在数组里面 */
  22. for(item of a1.entries()){
  23. console.log(item)
  24. }
  25. console.log(a1)
  26. </script>
  27. </body>
  28. </html>