Prototype.js does not set objects's constructor property properly

Discussion in 'Javascript' started by navneet.krg@gmail.com, Dec 5, 2007.

  1. Guest

    create a class myClass using prototype.js's Class.create()
    then create an object foo of that myClass
    then "object.constructor" will return
    "function Object() { [native code for Object.Object, arity=1] }"

    should be myClass

    does prototype.js does not set the constructor property properly

    if i create the class using
    function myClass(){};
    foo = new myClass()
    foo.constructor
    will give
    function myClass() {
    }
    , Dec 5, 2007
    #1
    1. Advertising

  2. RobG Guest

    On Dec 5, 7:39 pm, "" <>
    wrote:
    > create a class myClass using prototype.js's Class.create()
    > then create an object foo of that myClass

    [...]

    Questions specifically related to features or usage of particular
    libraries are off-topic here, you should try a Prototype.js news
    group, e.g.:

    <URL: http://groups.google.com.au/group/rubyonrails-spinoffs?hl=en&lnk=li
    >


    <FAQENTRY>

    Suggested new 2nd paragraph for FAQ #2.2 (updaated[1]):

    If your question relates to a particular javascript library, or
    conflicts between libraries, you should ask in a news group or forum
    that supports the library. The clj news group will consider questions
    realted to javascript within a library if no suitable answer is
    provided on the library-specific forum. Make sure you include a link
    to where you asked the question, or information on the responses you
    received.

    </FAQENTRY>

    1. <URL:
    http://groups.google.com.au/group/c...l=en&lnk=gst&q=FAQENTRY Robg#d4ca21cc1e264d8a
    >


    --
    Rob
    RobG, Dec 5, 2007
    #2
    1. Advertising

  3. On Wed, 5 Dec 2007 at 01:39:37, in comp.lang.javascript,
    wrote:
    >create a class myClass using prototype.js's Class.create()
    >then create an object foo of that myClass
    >then "object.constructor" will return
    >"function Object() { [native code for Object.Object, arity=1] }"
    >
    >should be myClass


    The ECMAScript standard does not require every object to have or inherit
    a 'constructor' property. Don't be surprised if you get an unexpected
    result. In this case it looks as though the prototype chain was created
    by doing new Object(); , and not altered later on.


    >does prototype.js does not set the constructor property properly
    >
    >if i create the class using
    >function myClass(){};
    >foo = new myClass()
    >foo.constructor
    >will give
    >function myClass() {
    >}


    You've forgotten to put quotes round the answer : it's the result of
    calling toString on a function object.

    John
    --
    John Harris
    John G Harris, Dec 5, 2007
    #3
  4. RobG wrote:
    > On Dec 5, 7:39 pm, "" <>
    > wrote:
    >> create a class myClass using prototype.js's Class.create()
    >> then create an object foo of that myClass

    > [...]
    >
    > Questions specifically related to features or usage of particular
    > libraries are off-topic here, you should try a Prototype.js news
    > group, e.g.:
    >
    > <URL: http://groups.google.com.au/group/rubyonrails-spinoffs?hl=en&lnk=li


    I seriously doubt this is a link to a *newsgroup*.

    > <FAQENTRY>
    >
    > Suggested new 2nd paragraph for FAQ #2.2 (updaated[1]):
    >
    > If your question relates to a particular javascript library, or
    > conflicts between libraries, you should ask in a news group or forum
    > that supports the library.


    NAK. That should be reworded so that the potential disadvantage of using
    the particular library can be pointed out here.

    > The clj news group will consider questions
    > realted to javascript within a library if no suitable answer is
    > provided on the library-specific forum.
    > Make sure you include a link to where you asked the question, or
    > information on the responses you received.


    NAK. I am not going to search the Web or login to a Web forum to determine
    whether or not the posting is to consider. Furthermore, it is not the
    newsgroup that considers it, but the subscribers of the newsgroup. And it
    should be reworded ("might") so that these people are not said to be
    compelled to reply.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
    Thomas 'PointedEars' Lahn, Dec 6, 2007
    #4
    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. Replies:
    2
    Views:
    331
    Alun Harford
    May 15, 2006
  2. Generic Usenet Account
    Replies:
    10
    Views:
    2,223
  3. Peter Michaux
    Replies:
    1
    Views:
    95
    Richard Cornford
    Oct 30, 2006
  4. Spam Catcher
    Replies:
    4
    Views:
    155
    Darko
    Nov 21, 2007
  5. wilq
    Replies:
    4
    Views:
    88
Loading...

Share This Page