JSFiddle - React, Tailwind, and code Playground

JavaScript

let h;
function f() {
  function g() { console.log(x); }
  h = function () { x=27; }
  let x = 0;
  g();  // prints 0
  x = 1;
  g();  // prints 1
  x = 3;
  return g;
}

let x=4; 
g = f();
g(); // prints 3
h();
g(); // prints 27