let words ='helloworld';let says ='i want to say ${words}';
console.log(says);
对象简化赋值
变量赋值简化
当变量名、属性名一致的时候可以省略,如下所示:
let name ='cmcandy';let words ='helloworld';let person ={
name:name,
words:words
}//等价于:let person ={
name,
words
}
方法省略function
let name ='cmcandy';let words ='helloworld';let person ={
name:name,
words:words
say:function(){
console.log('helloworld');}}//等价于:let person ={
name:name,
words:words
say(){
console.log('helloworld');}}