# 02 · var-vs-let **演示**:classic 脚本里的 `var` 会成为 `window` 属性,`let` 只活在脚本词法作用域里。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/17-pre-module-globals/02-var-vs-let/`;开 Console。 **预期控制台输出**: ```text legacyVar:global modernLet:not-global ``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/17-pre-module-globals/02-var-vs-let/tsconfig.types.json` **注意**:模块顶层即使写 `var` 也不会成为全局属性;模块有自己的作用域。