JSFiddle - React, Tailwind, and code Playground

by tchaffee

HTML

<script src="https://rawgit.com/eu81273/jsfiddle-console/master/console.js"></script>

JavaScript

var i = 10;

function foo() {
  var i = 2;
  
  function bar() {
    i = i + 1;
    console.log ('value of i when bar is declared inside foo: ', i);
  }
  
  return bar;
}

var barFunc  = foo();

barFunc(); // Runs in global scope but logs 3