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"