How to declare global variables when using the strict mode pragma

前端 未结 5 1453
梦如初夏
梦如初夏 2021-01-31 16:52

It\'s considered good practice to use a self-invoking function to wrap strict mode compliant code, often called the strict mode pragma:

(function(){
  \"use stri         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 16:58

    Benefit of alt 2 and 3 is that they keep all of the code inside the "container function." One line of code outside of the function is easy to miss when reading the code.

    Also:

    • "GLOB" should be the application's name. -- You want to allow for more than one application per html/js file without name collisions.

提交回复
热议问题