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>
 
// Case 1: IIFE
(function() {
  'use strict';
  console.log('Case 1 ' + String(this === undefined));
})();
// Case 2: Global function call
function bar() {
  'use strict';
  console.log('Case 2 ' + String(this === undefined));
}
bar();
// Case 3: IIFE in object method call
var obj = {
  foo: function() {
    (function() {
      'use strict';
      console.log('Case 3 ' + String(this === undefined));
    })();
  }
};
obj.foo();
// Case 4: Function call in object method call
var obj = {
  foo: function() {
    var bar = function() {
      'use strict';
      console.log('Case 4 ' + String(this === undefined));
    };
    bar();
  }
};
obj.foo();
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers