JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
(function() {
"use strict";
function Foo() {
function bar() {
console.log(this.x);
}
return {
bar,
get baz() {
var s = this;
return () => s.bar();
}
}
}
var a = new Foo();
a.x = 5;
a.bar();
a.baz();
var b = a.bar;
var c = a.baz;
//b(); // throws an error because `this` is not defined
c();
function wrapper(f) {
f();
}
wrapper(a.bar.bind(a)); // throws an error
wrapper(a.baz);
})();