(function() {var statement = "Im an idiot!"})();

Public service announcement!

Some time ago, I may have advised people here to use javascript like:

(function () {
  // some code here
})();

to hide variables and avoid them leaking into the global namespace.
I since realise this is no longer the best way to do it. If you're working on a project that uses jQuery (which Quest does), you should instead be using:

$(function () {
  // some code here
});

this does pretty much the same thing; but may delay the code slightly until the page has finished loading (a bit like Quest's on ready block, but not quite)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums