Part of your flaw is that javascript is a case sensitive language, so
Narcissus != narcissus;
It adds Narcissus to the global scope, omitting the var keyword, or Narcissus is already available in the global scope, or Narcissus already defined in the scope of this function.
Then we define it as a Narcissus object inside an anonymous function.
I can’t tell you why it does this, but it looks like it might already be inside the area where this refers to the object, and it wants to set the hostGlobal key to the global object, and not to the object’s realm now.
This is why it runs it as an anonymous function, since they are not executed in the global scope. Therefore, in its code, hostGlobal: this refers to a global object.
Of course, he could just use hostGlobal: window if this code also fails to run in non-browser environments like node.js, where the global object is global not window . Therefore, he could do this as a very unintuitive method of achievement.
hostGlobal: ( global === undefined )? window : global
Hope this helps
source share