hanyuxinting / Blog

记录点滴
1 stars 0 forks source link

《ECMAScript 6 入门 第二版》读书笔记 #3

Open hanyuxinting opened 7 years ago

hanyuxinting commented 7 years ago

读书会第三本书。 除了读书,更多的是应用。

hanyuxinting commented 7 years ago

ES6 简介

一个链接,判断各个端对ES6 的识别能力。

hanyuxinting commented 7 years ago

1. let & const

typeof x; // ReferenceError
let x;
typeof undeclared_variable // "undefined"
let a = 10;
a
10
let a = 3
VM972:1 Uncaught SyntaxError: Identifier 'a' has already been declared
    at <anonymous>:1:1
function b(data){let data = 0;}
b(1)
VM1037:1 Uncaught SyntaxError: Identifier 'data' has already been declared
    at <anonymous>:1:1
hanyuxinting commented 5 years ago

引用对象时,给对象属性改名

防止在同一个方法里出现多个同名变量,可以给对象属性重新命名。

const a = {b:1,c:2}
const {b:d,c:e} = a;
const f = {d,e}