1 karma · joined Jul 31, 2024 (2y ago) · 1 submissions
comment 2y ago · link · parent
This is the example I mean:
function demo() {
const bigArrayBuffer = new ArrayBuffer(100_000_000);
const id = setTimeout(() => {
console.log('hello');
}, 1000);
return () => clearTimeout(id);
}
globalThis.cancelDemo = demo();
[Edit]The blog post got updated with some links to other articles, which made it clear to me now. It looks like variables are only saved in the context/env if they are used in an inner function. Although one of the blog posts says that this is an implementation detail but at least it seems to work like this in FF/SM and V8.