How to keep the scope when calling setTimeout/setInterval in JavaScript
// Don't loose our scope
var self = this;
// Closures to the rescue
setTimeout(function() { self.hide() }, 500);
// Don't loose our scope
var self = this;
// Closures to the rescue
setTimeout(function() { self.hide() }, 500);