Skip to content

Instantly share code, notes, and snippets.

View lucas-silveira's full-sized avatar
🏠
Working from home

Lucas Silveira lucas-silveira

🏠
Working from home
View GitHub Profile
var theThing = null;
var replaceThing = function() {
var originalThing = theThing;
// Define um encerramento que faz referência a originalThing, mas nunca
// é realmente chamado. Mas, como esse encerramento existe,
// originalThing estará no ambiente léxico para todos
// os encerramentos definidos em replaceThing, em vez de ser otimizado
// a partir dele. Se você remover esta função, não haverá vazamento.
var unused = function() {
if (originalThing)
var theThing = null;
var replaceThing = function() {
var originalThing = theThing;
var unused = function() {
if (originalThing)
console.log("hi");
};
theThing = {
longStr: new Array(1000000).join('*'),
someMethod: function() {