On Sep 5, 6:32 am, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Yes, but every other implementation does that,

No, they don't.  In Firerfox 2 and 3 (and perhaps in earlier versions)
properties added to the window object are returned in reverse
order[1], in Opera 7 properties added to native objects were returned
in alphabetical order.

> so a lot of code
> implicitly relies on this.

Then it is bad code.

> You don't really expect programmers to read
> language specs, do you?

Yes, though simply reading it cover-to-cover is pointless.  They
should at least know enough about it to be able to find, read and
understand relevant sections where required.

How programmers learn a language is up to them, but they should at
least be aware of such fundamental principles.


1. Some play code, try it in Firefox and some other browser:

<div id="xx"></div>
<script type="text/javascript">
  function foo(obj) {
    var props = {alpha:'alpha', gamma:'gamma',
                 delta:'delta', beta:'beta'};
    for (var p in props) {
      obj[p] = props[p];
    }
    var x = [];
    for (p in obj){
      if (p in props){
        x.push(p);
      }
    }
    return x;
  }
  window.onload = function(){
    document.getElementById('xx').innerHTML = foo(this).join('<br>');
  }
</script>


--
Rob

Reply via email to