LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

JS
// global scope
var a = 1;
function one() {
  // alerts ‘1’
  document.writeln("Inside one() ->"+a+"
"); } one(); // global scope var b = 1; function two(b) { // functional scope //alerts the given argument, not the global value of 1 document.writeln("Inside two() ->"+b+"
") } two(2); // functional scope again function three() { var a = 3; // alerts ‘3’ document.writeln("Inside three() ->"+a+"
"); } three(); // Uncomment this to check functional scope var i,j; // i IS NOT known here // j IS NOT known here document.writeln("Before loop()-"+"i="+i+" j="+j+"
"); function loop(arr) { // i IS NOT known here // j IS NOT known here document.writeln("inside loop() before loops-"+"i="+i+" j="+j+"
"); for( var i = 0; i < arr.length; i++ ) { // i IS known here // j IS NOT known here document.writeln("inside i loop-"+"i="+i+" j="+j+"
"); }; // i IS known here // j IS NOT known here for( let j = 0; j < arr.length; j++ ) { // i IS known here // j IS known here document.writeln("inside j loop-"+"i="+i+" j="+j+"
"); }; // i IS known here // j IS NOT known here document.writeln("inside loop() after loops-"+"i="+i+" j="+j+"
"); } // i IS NOT known here // j IS NOT known here loop([1]); // Uncomment this to check block scope document.writeln("after loop()-"+"i="+i+" j="+j+"
");
Term
Wed, 12/27/2017 - 07:06

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv