Just wondering if there is anything different that happens under the hood? At first I thought that x would hold a copy of the sayHello function body but when stepping through the process in the browser's debugger the sayHello function is executed inside of the returnSomeFunction instead. So this got me wondering, is there a way to assign a function call to a variable (in this case x) where the return value is a function definition rather than holding a reference of the function that is inside of returnSomeFunction?
function returnSomeFunction() {
return function() {
console.log("Hello There!")
}
}
function returnSomeFunction() {
function sayHello() {
console.log("Hello There!")
}
return sayHello;
}
const x = returnSomeFunction();
x();