JSFiddle - React, Tailwind, and code Playground
by jacob414
HTML
<script src="https://raw.github.com/documentcloud/underscore/master/underscore-min.js"></script>
JavaScript
var singleton = {
obj1 : {
a : 5
},
obj2 : {
method1 : function(){
return this.obj1.a; // I added a return so we can inspect this.obj1.a
}
},
init : function() {
this.obj2.method1 = _.bind(this.obj2.method1, this)
}
}
singleton.init.call(singleton)
alert(singleton.obj2.method1())