How to keep the scope when calling setTimeout/setInterval in JavaScript

JavaScript posted 10 months ago by christian

   1  // Don't loose our scope
   2  var self = this;
   3  // Closures to the rescue
   4  setTimeout(function() { self.hide() }, 500);

Tagged settimeout, setinterval, javascript, scope, closures