JSFiddle - React, Tailwind, and code Playground
by Michael Seifert
JavaScript
test = (function() {
var currentInstance;
/* This won't work
function getInstanceId(){
return currentInstance.id;
}
*/
function test() {
this.id = 0;
currentInstance = this;
// this won 't work
this.getInstanceId = function() {
return currentInstance.id;
}
}
test.prototype.setId = function(id) {
this.id = id;
}
return test;
})();
var myTest = new test();
myTest.setId(1);
console.log(myTest.id)
console.log(test.getInstanceId());
//console.log(test.currentInstance.id);