Code 1 - Output in the following order:
undefined
42
Reason - The first output is undefined since when the function is invoked, it is invoked referencing the global object:
window.getPower() = getPower();
Code 2 - Outputs in the following order:
global/window object
object "b"
global/window object
Since we are using arrow function inside func2, this keyword refers to the global object.
Code 3 - Outputs in the following order:
"Vivek"
undefined
"Vivek"
Only in the IIFE inside the function f , the this keyword refers to the global/window object.