1.变量的解构赋值
const array = ['11111','22222','33333','44444'];
let [arr1,arr2,arr3,arr4] = array;
const dic ={
name:'jam',
age:30,
say:function(){
console.log('我是个好人');
}
};
let {name,age,say} = dic;
let {say} = dic;
2.模板字符串
1.声明
let str = `hello world`;
2.内容中可出现换行符
let str1 =`
<ul>
<li>111</li>
<li>222</li>
</ul>
`;
3.可拼接变量
let test = '123';
let str3 = `${test}456`;
3.对象的简化写法
// ES6允许在大括号里 直接写入变量和函数,作为对象的属性和方法
// key value一致,省略key
let name = 'hua';
let study = function(){
console.log('hello');
}
const school = {
name,
study,
// improve:function(){
improve(){
console.log(1111);
}
}
4.rest参数
// ES6 引入rest参数,用来获取函数的实参,代替arguments
// ES5
function date(){
console.log(arguments);
}
date("1111","2222","3333")
// ES6 rest参数 rest参数必须要放到参数最后
function test(...args){
console.log(args);//数组
}
test("1111","2222","3333")
网友评论