prototype.js functions in an array?

Discussion in 'Javascript' started by Emanuele D'Arrigo, Oct 22, 2006.

  1. Hi everybody,

    if you have a look to this page

    http://www.manu3d.com/jsTests/test.html

    you'll find a red rectangle. If you click on the rectangle
    the content of an "allegedly" empty array is printed out.
    As you will see, it isn't exactly empty.

    http://www.manu3d.com/jsTests/test.js

    holds the js code. It seems to me that this problem
    is related to prototype.js as the array shows as
    correctly empty if that file isn't sourced.
    But can anybody explain me why is this happening?

    Thank you.

    Manu
    Emanuele D'Arrigo, Oct 22, 2006
    #1
    1. Advertising

  2. Emanuele D'Arrigo

    Randy Webb Guest

    Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:
    > Hi everybody,
    >
    > if you have a look to this page
    >
    > http://www.manu3d.com/jsTests/test.html
    >
    > you'll find a red rectangle. If you click on the rectangle
    > the content of an "allegedly" empty array is printed out.
    > As you will see, it isn't exactly empty.
    >
    > http://www.manu3d.com/jsTests/test.js
    >
    > holds the js code. It seems to me that this problem
    > is related to prototype.js as the array shows as
    > correctly empty if that file isn't sourced.
    > But can anybody explain me why is this happening?


    Because prototype extends the Array object (often un-necessarily) and
    you are seeing the consequences of that. Another reason why prototype.js
    is frowned upon in this group.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Oct 22, 2006
    #2
    1. Advertising

  3. Randy Webb wrote:
    > Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:
    > > Hi everybody,
    > >
    > > if you have a look to this page
    > >
    > > http://www.manu3d.com/jsTests/test.html
    > >
    > > you'll find a red rectangle. If you click on the rectangle
    > > the content of an "allegedly" empty array is printed out.
    > > As you will see, it isn't exactly empty.
    > >
    > > http://www.manu3d.com/jsTests/test.js
    > >
    > > holds the js code. It seems to me that this problem
    > > is related to prototype.js as the array shows as
    > > correctly empty if that file isn't sourced.
    > > But can anybody explain me why is this happening?

    >
    > Because prototype extends the Array object (often un-necessarily) and
    > you are seeing the consequences of that. Another reason why prototype.js
    > is frowned upon in this group.


    It looks like the two newest versions of Prototype don't extend Object
    prototype anymore. However it doesn't look like there are any plans to
    stop extending the Array prototype.
    Peter Michaux, Oct 23, 2006
    #3
  4. Emanuele D'Arrigo

    RobG Guest

    Peter Michaux wrote:
    [...]
    > It looks like the two newest versions of Prototype don't extend Object
    > prototype anymore. However it doesn't look like there are any plans to
    > stop extending the Array prototype.


    Have they fixed the case where $() returns named elements instead of
    id'd ones in IE?

    e.g. given valid HTML:

    <div>
    <input name="foo" value="foo input">
    </div>
    <div id="foo">foo div<br>
    <button onclick="alert($('foo').tagName);">Call $('foo')</button>
    </div>

    What should the alert show: the div, the input, both or an error?


    --
    Rob
    RobG, Oct 23, 2006
    #4
  5. Emanuele D'Arrigo

    Randy Webb Guest

    Peter Michaux said the following on 10/22/2006 10:34 PM:
    > Randy Webb wrote:


    <snip>

    >> Because prototype extends the Array object (often un-necessarily) and
    >> you are seeing the consequences of that. Another reason why prototype.js
    >> is frowned upon in this group.

    >
    > It looks like the two newest versions of Prototype don't extend Object
    > prototype anymore. However it doesn't look like there are any plans to
    > stop extending the Array prototype.


    Did you notice that I said nothing about Object's though? <g>

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Oct 23, 2006
    #5
  6. Randy Webb wrote:
    > Because prototype extends the Array object (often un-necessarily) and
    > you are seeing the consequences of that. Another reason why prototype.js
    > is frowned upon in this group.


    Thanks for the confirmation Randy, and everybody else who answered.

    Manu
    Emanuele D'Arrigo, Oct 23, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xiangliang Meng
    Replies:
    1
    Views:
    1,576
    Victor Bazarov
    Jun 21, 2004
  2. June Lee
    Replies:
    2
    Views:
    785
    Jim Cobban
    Apr 13, 2008
  3. Replies:
    9
    Views:
    170
    Thomas 'PointedEars' Lahn
    May 26, 2006
  4. Replies:
    3
    Views:
    256
  5. javascript fish
    Replies:
    0
    Views:
    159
    javascript fish
    Oct 11, 2008
Loading...

Share This Page