zoukankan      html  css  js  c++  java
  • 重学ES系列之新型数据结构Map应用

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新型数据结构Map应用</title>
    </head>
    <body>

    </body>
    <script>
    // 1、
    // let num = 123;
    // let arr =[1,2,3];
    // let fun = function () {};
    // let obj = {};
    // const map1 = new Map();
    // map1.set(num,"q1"),
    // map1.set(arr,"q2");
    // map1.set(fun,"q3");
    // map1.set(obj,"q4");
    // console.log(map1);
    // console.log(map1.keys());
    // for (const key of map1.keys()) {
    // console.log(key);
    // }

    // 2、
    const map2 = new Map([
    ["a1","1"],
    ["a2","2"],
    ["a3","3"]
    ]);
    map2.set("a4","4");
    map2.delete("a2");
    console.log(map2.has("a2"));//false
    console.log(map2);
    let arr1 = [...map2.values()];//可以把所有的value转存到数组
    console.log(arr1);
    let arr2 = [...map2.keys()];//可以把所有的key转存到数组
    console.log(arr2);
    let arr3 = [...map2.entries()];//显示数组里面的所有内容
    console.log(arr3);
    for (const key of map2.keys()) {
    console.log(key);
    }
    // 适用于集合类型
    </script>
    </html>

  • 相关阅读:
    4.Spring系列之Bean的配置1
    3.Spring系列之IOC&DI
    2.Spring系列之HelloWorld
    1.spring系列之简要概述
    SVN 安装与使用
    6.用CXF编写基于Spring的WebService
    5.webService拦截器
    4.CXF所支持的数据类型
    APP消息推送及疑问解答
    VMware安装CentOS
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13272047.html
Copyright © 2011-2022 走看看