From 42c4e387e0d23e2a3ad25627f479b733a1f97adf Mon Sep 17 00:00:00 2001 From: dp~ <457509824@qq.com> Date: Sun, 22 Oct 2017 23:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=AA=E4=BE=8B=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var-let-const.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/var-let-const.md b/var-let-const.md index 00291d3..cb1a630 100644 --- a/var-let-const.md +++ b/var-let-const.md @@ -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`试试。 \ No newline at end of file