If the environment is the browser, then we can use
<script>
console.log(this === window);
</script>
to test that the this keyword points to the window object, which is also the global object (or some book calls it the "head object").
What if in node.js, is there such a name similar to window, so that
console.log(this === globalObjectName);
will print out true?
There is global. And this returns true when run from the main level:
this === global
But depending on what you are trying to test for:
require.main === module
may be more helpful. This tells you whether your module is running as the main one or is being "required".
I think what you mean is the global object.
You can find this in Node API.