Обновление движка V8, нужны изменения в статье "Замыкание"
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- documentation
Research direction
Open the closure article at https://learn.javascript.ru/closure and run the two supplied snippets in current V8 and Safari, checking the debugger behavior described in the issue. Update the example and explanation to reflect current V8 behavior, and verify that the Safari comparison remains accurate.
Written by the indexing model from the issue text.
Description
Соавтор нахождения и объяснения причины особенностей движка: @mirageN1349
Пример с особенностью движка в конце статьи теперь не работает (https://learn.javascript.ru/closure)

Теперь, если в лексическом окружении не используется переменная, то движок её не видит
Примеры:
- Здесь мы не используем переменную value1 в локальном лексическом окружении, связанном с функцией f, и движок её не видит
let value = "Сюрприз!";
function f() {
let value1 = "значение1";
let value = "ближайшее значение";
function g() {
console.log(value)
// alert(value1) в консоли НЕ выведет "значение1"
debugger;
}
return g;
}
let g = f();
g();

- Теперь мы используем переменную value1 в локальном лексическом окружении, связанном с функцией f, и движок её видит
let value = "Сюрприз!";
function f() {
let value1 = "значение1";
let value = "ближайшее значение";
function g1() {
console.log(value1)
}
function g() {
console.log(value)
// alert(value1) в консоли выведет "значение1"
debugger;
}
return g;
}
let g = f();
g();

По поводу примера из статьи: в safari, даже когда значение не используется, движок корректно сохраняет свойство лексического окружения (переменную)

- Dominant language
- HTML
- Stars
- 4.1k
- Forks
- 922
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from javascript-tutorial/ru.javascript.info
-
suggestion: tutorial
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
javascript-tutorial/ru.javascript.info#2187 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
javascript-tutorial/ru.javascript.info#2163 · 1 comment ·
-
[Баг]: Openbug
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
suggestion: tutorial
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
suggestion: tutorial
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in javascript-tutorial/ru.javascript.info
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·
-
NeedsTriage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
error Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
textual definition
Difficulty 1/5 Under an hour Newbie friendliness 90/100
geneontology/go-ontology#32653 ·