jgabios said:
i have firefox 3.0.8.
and i have the following code:
(function(){
function N(){
alert('N');
window.alert(...);
`alert' is no longer a JavaScript feature since version 1.4, and it has
never been a language feature in other ECMAScript implementations.
}
function Y(){
alert('Y');
See above.
Don't augment host objects.
One refers to the ECMAScript Global Object explicitly by `this' if the
caller is the Global Object or null, or e.g. by `_global' in local context
with `_global = this' in global context:
(
function ...(...) {
this.goog = ...
}
)()
or
var _global = this;
function ...(...)
{
_global.goog = ...
}
Usually you would declare the identifier a variable and make use of the
scope chain, though, or you would use the function as the object that it is.
var goog;
function foo(...)
{
goog = ...
/* or */
foo.goog = ...
/* or */
arguments.callee.goog = ...
}
})();
if i do goog.__parent__ it gives me null;
the code:
function A(){
alert('A');
}
window.A.__parent__ gives me reference to the window.
Consider that a happy coincidence. (Netscape/Mozilla.org) JavaScript is but
one of many ECMAScript implementations (see e.g. Microsoft JScript), and
`window' refers to a host object. (I have neither ever heard of that
property before nor did I need to make use of such, and I need two hands to
count the years I'm doing ECMAScript implementations now. But thanks for
mentioning, it will be added to the ECMAScript Support Matrix.)
is there another way to get a reference to the anonymous function
first listed as goog(it is Y).__parent__ goes to null?
IIUC,
(
function() {
function N(){
window.alert('N');
}
function Y() {
window.alert('Y');
}
return arguments.callee;
}
)()
However, one wonders what do you think you need this for, and why.
PointedEars