Hi Google Developers,
This might be the wrong place to post my question, but it feels like the right place, please let me know if it's not!
Part of the ECMA standard I believe is that Javascript consoles will display objects as arrays when the objects are array-like.
Such as: ["hello", "world"] for an object containing strings that are numerically indexed.
Array-like behaviour is defined as a length property and a splice method being present on the object, as well as numerically indexed properties.
Libraries like jQuery do exactly this.
I've been trying to take advantage of this behaviour and consider it desirable. However I have the additional requirement that my indexes use getters/setters to set them so that I can do some additional processing when they're modified.
However when I do this the above array is instead rendered as:
[undefined × 2]
However the object behaves otherwise exactly the same as a simple example.
See this Fiddle for a far better explanation:
http://jsfiddle.net/5YgAv/
So you see? Two very similar examples, however the presence of the getter has broken it in the console.
I've been debugging the latest Chromium dev tools and it appears that Chrome pushes a message at the console which essentially contains the getter function. However there's no way to modify the console source code so that it can invoke the function and get the value. If that were possible then we could modify the developer tools to handle getters and setters correctly.
What I'd like to know is if anyone has any insight into this interesting little bug or how it might be best fixed before I file it as a bug to be possibly long forgotten!
I'd like to fix it myself, but I'm not familiar with the high level architecture of Chrome so would appreciate some pointers on where it should be fixed?
I'm also open to a workaround that's elegant and allows me to do some special processing when any of the properties on my array-like object are modified.
So... Over to you guys....
[Ryan]