Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
模板字面量在js中可以理解为增强版的字符串,它用反引号(`)标识,类似php中的双引号。能够解析里面的变量。
代码如下:
<script>
let a = "hello",
b = "doctor";
let str = `${a} ${b}`;
console.log(str);
</script>
解构赋值是为了方便提取对象或者数组中的值,不用从数组、对象中一个个提取出来。
代码如下:
<script>
let arr1 = ["a", "b", "c", "d"];
let [e, f, g, h] = arr1;
console.table([e, f, g, h]);
</script>
对象字面量中的属性值,如果引用了相同作用域中的”同名变量”,则可以省去不写
代码如下:
<script>
let bird = {
move: "move",
color: "color",
};
let { move, color } = bird;
let butterfly = {
move,
color,
};
console.log(butterfly);
</script>