self
Given the troubles with adding a common global reference in the spec, just use self
. self
already exists in browser and worker environments. This script just adds a circular reference to the already existing global in the form of self
if it's not already there.
This package was inspired by @pluma's comments here and here about self
being a red herring. Although self
is not as pretty as global
, it works.
usage
// universal js code
require('@obedm503/self');
self.console.log(self.self === self); // true