<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> </body> <script> //es7中求次方; var a=6**3; console.log(a) //es7 判断是否含有指个字符,只能用于简单型字符 var b=[1, 2, 3] console.log(b.includes(3)) //es7 中数组去重; Set方法! const numbers = [2,3,4,4,2,3,3,4,4,5,5,6,6,7,5,32,3,4,5] var c=[...new Set(numbers)] console.log(c) //取出单词中不重复字母 var d="yangxiaoxin" var steMe=new Set(d); console.log(steMe) var e=["yang","xiao","xin"] var yang=new Set(e); console.log(yang); console.log(yang.has("xing")); var f=[...yang]; console.log(...yang,f) var g =[1, 2, 3] var h = [2, 3, 4]; // 并集 var s = Array.from(new Set([...g, ...h])); // [ 1, 2, 3, 4 ] console.log(s) // 交集 var bSet = new Set(h); var interestSet = g.filter(v => bSet.has(v)); // [ 2, 3 ] console.log(interestSet) //差集 var interestSet = g.filter(v => !bSet.has(v)); // [ 1 ] console.log(interestSet) </script> </html>
原文:https://www.cnblogs.com/yangxiaoxin/p/11352376.html