The scope of JavaScript

What are the advantages and disadvantages of a design pattern like

js scope?
what gorgeous operations are bosses doing with scope?

Jul.16,2021

weigh the advantages and disadvantages of

Global scope = A function body access considers the nearest principle level weight principle
function scope = = when a function scope variable is out of scope, it will be cleaned up
let is considered as a local scope = = local access to avoid contamination in the global scope

actions

jquery is a typical example of a function scope. Large closures are used to avoid polluting global scope variables.
             

1. Advantages: scope protects variables from contamination
external access to internal variables

2. Difference: no dynamic scope
function internal variable references have nothing to do with the runtime, but are related to the location of the variable definition
see the following code

  

pollutes the environment, so use the global as little as possible. Let variable declarations that support block-level scopes are provided in ES6.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bb1d-2c29c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bb1d-2c29c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?