JS advanced – sandbox

Time:2020-5-10

sandbox

 

Sandbox: environment, black box, simulating the real world in a virtual environment, doing experiments, the experimental results are the same as the real world results, but will not affect the real world
 
 
var num=10;
console.log(num+10);

 

//Sandbox - small environment
    (function () {
      var num = 10;
      console.log(num);
    })();

 

//Sandbox - small environment
    (function () {
      var num = 20;
      console.log(num + 10);
    }());

 

There is no interaction inside and outside

    var num = 100;
    (function () {
      var num = 10;
      console.log(num);//10
    }());


    console.log(num);//100

 

 

 

Recommended Today

You have to know about JVM garbage collection

catalogue 1、 Four citation methods1.1 strong reference1.2 soft reference1.3 weak reference1.4 phantom reference 2、 How to judge whether the object is garbage2.1 reference counting method2.2 root accessibility analysis 3、 Garbage collection algorithm3.1 mark sweep3.2 mark compact3.3 mark copy 4、 Garbage collector4.1 classification and characteristics4.1.1 serial4.1.2 throughput priority4.1.3 priority of response time4.2 serial garbage collector details […]