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() {
    function foo() {
        return 'a';
    }
    return foo();
    // This function gets hoisted up at runtime, replacing the already existing function. So "b" gets returned.
    function foo() {
        return 'b';
    }
})();
console.log(result); // "b"
// Demonstration of what happens at runtime:
var result = (function() {
    var foo = function foo() {
        return 'b';
    }
    return foo();
})();
console.log(result); // "b"
Output

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

Dismiss x
public
Bin info
miguelmotapro
0viewers