'Different results came from different editor in terms of .this keyword

Everyone. I am learning javascript. I ran this code: (below)

function x(){
  return this;
}

console.log(x() === global);

in Atom editor, then got a result which was "false". (please see my added picture) However, I turned to another online editor to run the same code then got the result "true" ! (please see my added picture)

My question one is : Is it Atom's problem leading to different results ?

My question one two : I heard that "===" is named strict equality, which means it will be "false" if left operand is different with right operand. But, in the code I just have posted, in this line "(x() === global)", the result is "true" while the left operand and the right operand are certainly different, so what is wrong with it, is it that I am still not learning about some fundamental concepts?

Waiting for your answer Hopefully! enter image description here

enter image description here



Solution 1:[1]

in "sloppy mode" this keyword in a function refers to the global object. while in strict mode its value is undefined. I'm not sure about your editor's settings but I would say both are correct depending on the settings. It could be that atom sets strict mode by default while the other editor doesn't.

More on what is strict mode and what does it effect and why it is used for in MDN documentation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Neveen Atik