Skip to content

Commit

Permalink
加个例子
Browse files Browse the repository at this point in the history
  • Loading branch information
dptms committed Oct 22, 2017
1 parent 5f5f7a9 commit 42c4e38
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions var-let-const.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ person = {name:'tms'}; // 报错
person.age = 40; // ok
```
ps : 以上的例子一个是改变了对象,一个是改变了对象的属性,如果完全不想更改一个对象,可以使用`Object.freeze(obj)`

# 再来个例子
```
for (var i = 1; i < 10; i++) {
console.log(i);
setTimeout(function () {
console.log(`i:${i}`);
}, 1000);
}
```
这里把 `var` 可以换成 `let`,`const`试试。

0 comments on commit 42c4e38

Please sign in to comment.