Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Обновление движка V8, нужны изменения в статье "Замыкание"

Open
#1,820 1 comment 0 reactions 0 assignees View on GitHub

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)
image

Теперь, если в лексическом окружении не используется переменная, то движок её не видит
Примеры:

  1. Здесь мы не используем переменную 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();

image

  1. Теперь мы используем переменную 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();

image


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

Dominant language
HTML
Stars
4.1k
Forks
922
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from javascript-tutorial/ru.javascript.info

All issues in javascript-tutorial/ru.javascript.info

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.