Files
front-end-example/03-javascript-core/11-var-and-scope/README.md
charlie 877acb5a8f feat: Add JavaScript core exercises and solutions
- Implemented exercises for array high-order methods, memory and execution, switch statements, and final review.
- Added starter and answer files for each exercise to facilitate learning.
- Created a runner HTML file to execute JavaScript code and display console outputs.
- Updated README files to include exercise objectives, tasks, and usage instructions.
2026-03-13 11:09:19 +08:00

31 lines
843 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 练习 11var、let、const 与提升
## 目标
理解 `var``let``const` 的基本区别,尤其是作用域和提升差异。
## 你要练什么
- `var`
- `let`
- `const`
- 变量提升
- 块级作用域
- 函数作用域
## 任务
请完成一个“作用域观察”脚本,要求:
- 观察 `var` 声明前为什么能访问到 `undefined`
-`var` 声明一个函数内部变量
-`let` 声明一个代码块内部变量
- 在可访问的位置输出它们
- 观察为什么 `var` 在块外还能访问,而 `let` 不行
- 再写一段代码证明 `const` 不能被重新赋值
## 文件
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/03-javascript-core/11-var-and-scope/starter.js)
- [answer.js](/Users/lijiaqing/home/wwwroot/front-end-example/03-javascript-core/11-var-and-scope/answer.js)