Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var result = (function() {
    var x = 1;
    return (function () {
        return x;
        // this x gets hoisted to the top of the function,
        // and never gets initialized because it's after the return.
        var x = 2;
    })();
})();
console.log(result); // undefined
// Demonstartion of what happens at runtime:
var result = (function() {
    var x = 1;
    return (function () {
        var x;
        console.log(x); // undefined
      
        return x;
    })();
})();
console.log(result); // undefined
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
miguelmotapro
0viewers