摘要: 1 { 2 //有默认值的后面如果有参数必须要有默认值 3 function test(x,y="world"){ 4 console.log(x,y) 5 } 6 test('hello');//hello world 7 test('hello',"kill");//hello kill 8 9 } 10 { 11 ... 阅读全文
posted @ 2018-06-21 17:22 chenlw101 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 1 //数组扩展 2 { 3 let arr=Array.of(3,4,6,7,9,11);//可以是空 4 console.log('arr=',arr);//[3,4,6,7,9,11] 5 } 6 { 7 //Array.from把伪数组或者集合变为数组 8 let p=document.querySelectorAll('p'); 9 ... 阅读全文
posted @ 2018-06-21 16:10 chenlw101 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 1 { 2 //Number.isFinite数字是有尽的 3 console.log(Number.isFinite(15));//true 4 console.log(Number.isFinite(NaN));//false 5 console.log(Number.isFinite('true'/0));//false 6 co... 阅读全文
posted @ 2018-06-21 15:39 chenlw101 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 1 //字符串扩展 2 { 3 console.log('a','\u0061'); 4 console.log('s','\u20BB7');//超过了0xffff 5 6 console.log('s','\u{20BB7}');//如果超过就用{}包裹 7 8 } 9 { 10 //es5中 11 let s='𠮷'; 12 ... 阅读全文
posted @ 2018-06-21 15:08 chenlw101 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 1 //正则扩展 2 { 3 let regex=new RegExp('xyz','i'); 4 let regex2=new RegExp(/xyz/i); 5 6 console.log(regex.test('xyz123'),regex2.test('xy')); 7 //后面的修饰符i覆盖原来的ig修饰符 8 let rege... 阅读全文
posted @ 2018-06-21 14:09 chenlw101 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 1 //解构赋值 2 3 { 4 let a,b,rest; 5 [a,b]=[1,2]; 6 console.log(a,b); 7 } 8 //数组解构赋值 9 { 10 let a,b,rest; 11 [a,b,...rest]=[1,2,3,4,5,6]; 12 console.log(a,b,rest); 13 } ... 阅读全文
posted @ 2018-06-21 13:33 chenlw101 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1 function test(){ 2 //let只在块作用域有效 3 for(let i=1;i<3;i++){ 4 console.log(i); 5 } 6 //es6严格模式,变量未声明,不可以用 7 //console.log(i); 8 //let 里面不可以声明两个相同的变量 9 let a... 阅读全文
posted @ 2018-06-21 11:35 chenlw101 阅读(75) 评论(0) 推荐(0) 编辑