JSFiddle - React, Tailwind, and code Playground
JavaScript
var obj = {
st: false,
prop: {
f: function () {
console.log('call f, ' + this.st); // При первом вызове undefined, в последующих true
this.st = true;
}
},
init: function () {
var that = this;
var time;
that.st = false;
document.addEventListener('click', function () {
var st = that.st;
console.log('click st, ' + st); // всегда false
if ( st === false ) {
that.prop.f();
console.log('click');
time = setTimeout(function() {
console.log('timeout ' + that.st); // всегда false
that.st = false;
}, 3000);
};
});
}
}
obj.init();