es6

set:会去重

var arr=["1","1","2"]; //长度为3

var list =new Set(["sun","sun","git","svn"])  //长度为3

console.log(list.size);//3

list.delete("svn")  //true

list.delete("abc")  //false

list.has("sun")  //true

list.add("test")  //在后面添加成功

list.clear(); //清空后length=0
let title = "我是标题";
let tpl = `测试:${title}`  

//tpl 的值为:"测试:我是标题"

新增的方法:

"helloworld".includes('Y') //false

"hellworld".startsWith('s')  //false

"hellworld".endsWith('d')  //true 注意区分大小写


"hao ".repeat(10) //"hao hao hao hao hao hao hao hao hao hao "


let[a,b,c]="nih"

console.log(a)  //  n
console.log(b)  //  i
console.log(c)   //  h


let {length} ="sdfsdfsdf";
//length长度为:9


let {floor,pow}=Math;
let a=1.9;
console.log(floor(a));

变量的解构和复制(好早之前写的了,没测试,先放着)

 1 //var obj={
 2 // a:1,
 3 // b:2
 4 //}
 5 
 6 //let a = 0;
 7 //({ a, b } = obj);
 8 //console.log(a)
 9 //console.log(b)
10 
11 
12 
13 //let {a:A,b}=obj;
14 //console.log(A)
15 //console.log(b)
16 
17 
18 //let { a,b }=obj;
19 
20 //console.log(a)
21 //console.log(b)
22 
23 
24 //let { c,b }=obj;
25 //console.log(c) //undefined
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 //var a = 1, b = 2, c = 3;
36 //var [a,b,c] = [1,2,3];
37 //var [a,[b,c]] = [1,[2,3]];
38 //var a = 1;
39 //let b = 2;
40 //console.log(a);
41 //console.log(b);
42 
43 
44 
45 //let [a,b,c]=[1,2];
46 //c会变成undefined
47 
48 
49 
50 
51 //es6 解构赋值数组
52 //var [a,b,c='default',d='default'] = [1,2,3];
53 //console.log(a)
54 //console.log(b)
55 //console.log(c)
56 //console.log(d)
57 
58 
59 
60 //let 一个方法 代码域
61 
62 //if (true) {
63 // var a = 1;
64 // let b = 2;
65 //}
66 
67 //console.log(a);
68 //console.log(b); //会报错
69 
70 
71 
72 //var a = 1;
73 
74 //function foo() {
75 
76 // if (false) {
77 
78 // var a = 2;
79 // }
80 
81 // console.log(a); //a 会变成undefined
82 //}
83 
84 //foo()
85 
86 
87 
88 //console.log(a);//a 会变成undefined
89 //var a;
原文地址:https://www.cnblogs.com/hanliping/p/10705539.html