-
-
Save pjanik/4b05cf46ba98a3e4d502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function Foo() { | |
this.bigData = new Array(5000000).join("XXXXX"); | |
this.smallData = "bla bla"; | |
} | |
Foo.prototype.m = function() { | |
var smallData = this.smallData; | |
$(window).on('click', function() { | |
console.log(smallData); | |
}); | |
}; | |
window.f = new Foo(); | |
window.f.m(); | |
delete window.f; | |
}()); | |
vs | |
(function() { | |
function Bar() { | |
var bigData = new Array(5000000).join("XXXXX"); | |
var smallData = "bla bla"; | |
return { | |
m: function() { | |
$(window).on('click', function() { | |
console.log(smallData); | |
}); | |
} | |
}; | |
} | |
window.b = new Bar(); | |
window.b.m(); | |
delete window.b; | |
}()); | |
vs | |
(function() { | |
function Bar() { | |
var bigData = new Array(5000000).join("XXXXX"); | |
var smallData = "bla bla"; | |
return { | |
m: function() { | |
$(window).on('click', function() { | |
console.log(smallData); | |
bigData += "X"; | |
}); | |
} | |
}; | |
} | |
window.b = new Bar(); | |
window.b.m(); | |
delete window.b; | |
}()); | |
vs | |
(function() { | |
function Bar() { | |
var bigData = new Array(5000000).join("XXXXX"); | |
var smallData = "bla bla"; | |
return { | |
m: function() { | |
$(window).on('click', function() { | |
console.log(smallData); | |
}); | |
}, | |
n: function() { | |
bigData += "X"; | |
} | |
}; | |
} | |
window.b = new Bar(); | |
window.b.m(); | |
delete window.b; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment