JSFiddle - React, Tailwind, and code Playground

by Jelgab

HTML

<h3>
Closure 002
</h3>
<div id = "Resultados" />

JavaScript

//Closure 002
function printResults( theValue ){
   $("#Resultados").append( theValue );
   $("#Resultados").append( $("<br/>") );
}

var variableGlobal = 100;

function probarAlcance01() {

  (
    function (parametroNivel1) {
      var variableNivelFuncion1 = 1;

      (
        function( parametroNivel2 ) {
          var variableNivelFuncion2 = 2;

          printResults( "Variable global : "          + variableGlobal        );
          printResults( "Parametro Nivel 1 : "        + parametroNivel1       );
          printResults( "Variable Nivel Funcion 1 : " + variableNivelFuncion1 );
          printResults( "Parametro Nivel 2 : "        + parametroNivel2       );
          printResults( "Variable Nivel Funcion2 : "  + variableNivelFuncion2 );
        }
      )( 7 );

      printResults( "<hr/>" );
      printResults( "A nivel de función 1, Parametro Nivel 2 : "       + typeof  parametroNivel2       );
      printResults( "A nivel de función 1, Variable Nivel Funcion2 : " + typeof  variableNivelFuncion2 );

    }
  )(5);

  printResults( "<hr/>" );
  printResults( "Justo afuera de nivel función 1, Parametro Nivel 1 : "        + typeof parametroNivel1       );
  printResults( "Justo afuera de nivel función 1, Variable Nivel Funcion 1 : " + typeof variableNivelFuncion1 );
  printResults( "Justo afuera de nivel función 1, Parametro Nivel 2 : "        + typeof parametroNivel2       );
  printResults( "Justo afuera de nivel función 1, Variable Nivel Funcion2 : "  + typeof variableNivelFuncion2 );

} /*function probarAlcance01()*/
  
  probarAlcance01();