Home > Web Front-end > JS Tutorial > Do `let` Statements Create Global Object Properties in JavaScript?

Do `let` Statements Create Global Object Properties in JavaScript?

Mary-Kate Olsen
Release: 2024-12-26 11:52:09
Original
691 people have browsed it

Do `let` Statements Create Global Object Properties in JavaScript?

Global Object Property Creation in JavaScript

In JavaScript, the question arises: do let statements contribute to the creation of properties on the global object?

Unlike var declarations, which create global object properties, let declarations in ES6 have lexical scoping and block visibility. However, the question remains whether they impact the global object.

According to the ECMAScript specification, the answer is no. The global environment record comprises two components: an object environment record and a declarative environment record. Built-in globals, FunctionDeclarations, GeneratorDeclarations, and VariableStatements create bindings stored in the object environment record, which is linked to the global object.

However, all other declarations, including let, are contained in the declarative environment record. This record employs an internal data structure for binding storage, making it inaccessible to the global object.

Therefore, let statements do not create properties on the global object.

The above is the detailed content of Do `let` Statements Create Global Object Properties in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template