window vs global var

JavaScript performance comparison

Revision 2 of this test case created by KDO

Info

Check the performance of window.variable = {} vs var variable = {} in global context

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
window, undeclared
(function() {
  var MR = window.MR || {};
})();
pending…
no window, undeclared
(function() {
  var MR = MR || {};
})();
pending…
window, delcared
MR = {};
(function() {
  var MR = window.MR || {};
})();
pending…
no-window, declared
MR = {};
(function() {
  var MR = MR || {};
})();
pending…
Sans window et sans fonction anonyme
var MR = {}; // Déclaration du namespace, il EST alors dans window.MR
// Utilisation du namespace pour l'application
MR.truc = 4;
pending…
no-window et autre façon PROPRE
// Déclaration du namespace, il EST alors dans window.MR
var MR = {
  truc: false
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment