how to access global scope in to local scope using javascript examples

JavaScript
var showState = function() {
  console.log("Idle");
};

function showState() {
  console.log("Ready");
} 

showState();            // output: Idle
Source

Also in JavaScript: