@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Document</title>
+</head>
+<body>
+ <script>
+ let arr = [1,2,3,4,5];
+ // find() 查找数组中第一个符合条件的值
+ // let num = arr.find(function(val,index,arr){
+ // return val > 2;
+ // });
+ // console.log(num);
+
+ // findIndex() 查找数组中第一个符合条件的索引
+ // let index = arr.findIndex(function(val,index,arr){
+ // console.log(index);
+ // for of 循环遍历数组中的每个元素
+ // 语句方法 定义一个变量(接收数组中的每个元素) of 循环的数组
+ // key() 方法返回数组的索引值
+ // console.log(arr.keys());
+ // for(let item of arr.keys()){
+ // console.log(item);
+ // }
+ // value() 方法返回数组的值
+ // for(let item of arr.values()){
+ // entries() 方法返回数组,数组包含索引值和值
+ for(let item of arr.entries()){
+ console.log(item);
+ }
+ </script>
+</body>
+</html>
@@ -0,0 +1,42 @@
+ // Set 数据结构
+ // 无序的、不重复的集合
+ // 可以存储任意类型的数据
+ // 值是唯一且不可重复
+ let set = new Set();
+ // add() 方法添加元素
+ set.add("张三");
+ set.add("李四");
+ set.add("王五");
+ // delete() 方法删除元素
+ set.delete("张三");
+ // has() 方法判断元素是否存在
+ console.log(set.has("李四"));
+ // clear() 方法清空集合
+ // set.clear();
+ // size() 方法返回集合的大小
+ console.log(set.size);
+ // 遍历集合
+ // for(let item of set){
+ // console.log(set);
+ // weakSet() 方法创建弱集合
+ let weakSet = new WeakSet();
+ weakSet.add({a:1});
+ weakSet.add({b:2});
+ // Map() 方法创建映射
+ let map = new Map();
+ // set() 方法添加映射
+ map.set("张三",1);
+ map.set("李四",2);
+ map.set("王五",3);
+ // get() 方法获取映射
+ console.log(map.get("张三"));
+ // delete() 方法删除映射
+ map.delete("李四");
+ // has() 方法判断映射是否存在
+ console.log(map.has("王五"));
+ // clear() 方法清空映射
+ // map.clear();
+ // size() 方法返回映射的大小
+ console.log(map.size);
+ // 遍历映射
+ for(let item of map){
+ console.log(map);
+ // weakMap() 方法创建弱映射
+ let weakMap = new WeakMap();
+ // add() 方法添加映射
+ weakMap.set({a:1},1);
+ weakMap.set({b:2},2);
+ console.log(weakMap);
@@ -0,0 +1,13 @@
+ let arr = [1,2,3,4,1,2,3,4,5,3,4,6,7,8,9]