Re: <FAQENTRY> 4.41 correction



Křištof Želechovski <giecrilj@xxxxxxxxxxxx> wrote:
At <http://jibbering.com/faq/index.html#FAQ4_41>
IS
Microsoft introduced a shortcut that can be used to reference
elements which include an ID attribute where the ID becomes a
global variable.
SHOULD BE
Microsoft introduced a shortcut that can be used to reference
elements THAT ARE NOT FORM CONTROLS WITHIN A FORM ELEMENT

In the context of question answered in the FAQ that is an inconsequential detail. (There is no sense in telling someone about never being able to reference a particular from of IDed element by Identifier when they are asking why accessing IDed elements by Identifier does not work in all environments.)

which include an ID attribute where the ID becomes A PROPERTY
OF THE GLOBAL WINDOW OBJECT

The only practical distinction between a global variable and a property of the global object is that a property of the global object can be deleted and a global variable cannot be deleted. The properties of the global object that result form IDed elements in the document on IE cannot be deleted.

and the scope of the window object

Objects do not have scopes, only functions and execution contexts have them.

is at the bottom of the symbol lookup stack..

The global object is at the end of all scope chains. ('lookup stack' has no meaning in ECMAScript).

In other words, if your design for Microsoft Internet
Explorer, you should use the syntax WINDOW.DEVID

Should you? What is wrong with using - document.getElementById("DEVID") -, as that works fine in IE as well as other browsers?

to avoid name clash

You would only risk a naming clash if making the reference from an execution context that had an object on its scope chain that had a property named "DIVID, which would itself be symptomatic of inappropriate code design (with regard to variable/property naming).

and make symbol lookup more efficient.

The old wives tail that qualifying property accessors in IE with - window - makes resolving them faster has been demonstrated false often enough by now to make repeating it in public a poor idea.

Richard.

.



Relevant Pages

  • Re: menus in JS or CSS - pros? cons?
    ... their scope chains refer to the global object). ... attaching event handlers to _any_ object that has ... have the global object in its scope, and therefore a reference to the object ...
    (comp.lang.javascript)
  • Re: JavaScript knowledge test
    ... The assignment can produces a runtime error when the object being assigned to is a host object and it throws an exception when the assignment is made to an 'x' proeperty. ... on IE if no global 'x' variable is declared but an element exists in the DOM with the ID attribute "x" then IE creates an 'x' proeprty of the global object and assigns it a reference to the DOM element. ... The assigning of the returned inner function form that example to an intrinsic event property of a DOM node does result in the DOM node having an indirect reference to a JS object, but so long as the JS object does not then hold a reference to the DOM node the circle is not closed and no garbage collection issues follow. ...
    (comp.lang.javascript)
  • Re: this confusion
    ... by Mike Winter: ... assignment being attained through the function.prototype.call/apply ... calls in accordance with the way in which the reference to the method ... "this" is assigned a reference to the global object. ...
    (comp.lang.javascript)
  • Re: RFC: Building the Perfect Tabbed Pane (an tutorial article)
    ... a reference to the functions involved. ... The handler has to have the element in it's closure. ... a handle for the wrapped function to use. ... I assume you mean that properties of the Global Object are within the ...
    (comp.lang.javascript)
  • Re: strange grammar about volatile and operator overload
    ... actually in the definition/declaration of the global object, ... not marked as volatile. ... it's not treated as volatile or const. ... x is accessed via vr reference, ...
    (microsoft.public.vc.language)