eval‘d, which compiles it into an executable form and then immediately executes it. That execution can leave artifacts in the window’s global object.
The global object is the global namespace that holds the top level functions and global variables. Variables which are not explicitly defined are implied global variables, and their names are also kept in the global object. This was a convenience for the little scripts that Navigator 2 was expected to support. In the decade since NS2, those little scripts have grown into Ajax applications, and the true nature of the global object is revealed:
Global variables are evil.
Yahoo’s single global is
YAHOO. It is spelled in all caps to identify it as something special, since all lower case is ordinary and initial caps indicates a constructor. Being in all caps, it is unlikely that someone would use it accidentally, which further reduces the likelihood of collision.
Generally a shallow tree is better than a deep tree. One could imagine that
YAHOO.util.Dom.get could have been factored more compactly perhaps as
YAHOO.get. And perhaps someday it will, but for now
YAHOO.util.Dom.get is not measurably slower, and it is helping Yahoo to manage its evolving codebase. (And if you don’t like the length, you only have to type it once. See
with Statement Considered Harmful.)