Loading ...
Sorry, an error occurred while loading the content.

Re: Use of a.push()

Expand Messages
  • Douglas Crockford
    ... This question is way off topic for this group. This group is about JSON, not JavaScript coding. But to answer your question, the first form is slightly
    Message 1 of 3 , Jan 3, 2006
    • 0 Attachment
      > Is there any reason why this is used:
      >
      > function e(s) {
      > a[a.length] = s;
      > }
      >
      > rather than
      >
      > function e(s) {
      > a.push(s);
      > }

      This question is way off topic for this group. This group is about
      JSON, not JavaScript coding.

      But to answer your question, the first form is slightly faster and
      will run on older language processors.
    • ingliss
      ... Hmmm. Well, if you say so, but I d rather taken my lead as to relevance from the post where you discuss Javascript efficiency in the parse function :-) ...
      Message 2 of 3 , Jan 3, 2006
      • 0 Attachment
        --- In json@yahoogroups.com, "Douglas Crockford" <douglas@c...> wrote:
        >
        > > Is there any reason why this is used:
        > >
        > > function e(s) {
        > > a[a.length] = s;
        > > }
        > >
        > > rather than
        > >
        > > function e(s) {
        > > a.push(s);
        > > }
        >
        > This question is way off topic for this group. This group is about
        > JSON, not JavaScript coding.
        >


        Hmmm.

        Well, if you say so, but I'd rather taken my lead as to relevance from
        the post where you discuss Javascript efficiency in the parse
        function :-)


        > But to answer your question, the first form is slightly faster and
        > will run on older language processors.
        >

        Ok, I'd have guessed it would be slower.
      Your message has been successfully submitted and would be delivered to recipients shortly.