Code:
function foo () {
console.log(“Simple function call”);
console.log(this === window);
}
foo();
Output:
[Running] node “c:\Users\David Garcia\Desktop\CODING\PRACTICE\JS\script.js”
Simple function call
c:\Users\David Garcia\Desktop\CODING\PRACTICE\JS\script.js:3
console.log(this === window);
^
ReferenceError: window is not defined
at foo (c:\Users\David Garcia\Desktop\CODING\PRACTICE\JS\script.js:3:24)
at Object. (c:\Users\David Garcia\Desktop\CODING\PRACTICE\JS\script.js:7:1)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.5.1
[Done] exited with code=1 in 0.35 seconds
Goal: I’m trying to obtain this output:
“Simple function call”
true