2

is there a way to access an external variable inside a javascript function ? In other words, is there an equivalent of "use" in php

function ($quantity) use ($tax, &$total) { .. };

The code i'm struggling with is the following :

function removePosition(menu) {
    msgManager.confirm('Delete ?').then(() => {
        menu.closest('.clockingPositionContainer').remove();
    });
}
Randy Arnold
  • 143
  • 7

1 Answers1

0

Scope is the region of the codebase over which an identifier is valid.

The four scopes are:

  • Global - visible by everything
  • Function - visible within a function (and its sub-functions and blocks)
  • Block - visible within a block (and its sub-blocks)
  • Module - visible within a module

Read More Here

Dean Van Greunen
  • 5,060
  • 2
  • 14
  • 28