Follow

javascript crimes 

The following causes a runtime error:

function factory(callback) {
callback();
return () => console.log(
"crime performed");
}

const func = factory(() => {
func();
});
// TypeError: func is not a function

But the following works:

function factory(callback) {
callback();
return () => console.log(
"crime performed");
}

const func = factory(() => {
setTimeout(() => func(), 0);
});
// "crime performed"
Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.