closures - uninitialized vs undefined

Đang mở
#3,895 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
55/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với các phần về môi trường từ vựng và hàm lồng nhau trong bài viết về closure, sau đó so sánh các nhãn trong lexenv-nested-makecounter-2.svg và lexenv-nested-makecounter-3.svg. Xác minh xem các sơ đồ có nên phân biệt với undefined hay không, và chỉ cập nhật các SVG đó nếu hành vi của JavaScript ủng hộ việc sửa như đề xuất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

in this article, we are discussing lexical environments, and the scope of variables.
upon initialization, variables are defined as <unitialized> because "the engine knows about the variable, but it cannot be referenced until it has been declared with let"

Image Image

later in the article, when referencing nested lexical environments in functions, a variable is initialized as undefined. from my understanding, this is incorrect, as the engine knows about the variable, but is not referenced yet since it hasn't been declared.

Image Image

i believe that we need to change the following SVG's to reflect this change:
https://github.com/javascript-tutorial/en.javascript.info/blob/master/1-js/06-advanced-functions/03-closure/lexenv-nested-makecounter-2.svg
https://github.com/javascript-tutorial/en.javascript.info/blob/master/1-js/06-advanced-functions/03-closure/lexenv-nested-makecounter-3.svg

if this is an incorrect assumption, please help me understand why it's undefined instead of uninitialized! i'd love to learn more about how this all works.

Ngôn ngữ chính
HTML
Star
25.5k
Fork
4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của javascript-tutorial/en.javascript.info

Tất cả issue của javascript-tutorial/en.javascript.info

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.