> Lasse Reichstein Nielsen wrote:
> I think we have been talking about the subject from different angles.
> If you entire point is that the current implementations implement
> objects with special handling of numeric indices, then it appears
> to be correct. The explanation using "casting" and "Baby Care" isn't
> very clear, though. It can be stated much shorter, e.g.:
>
> ECMAScript uses strings for property names. Doing a lookup on
> a number gives the same as first converting the number to a
> string.
>
> Many current implementations optimize lookup by numbers by using
> the numbers as keys internally, instead of their string representation.
> That means that a lookup with a number index is faster in such an
> implementation, than using a string representation of the number.
> This is the opposite of a literal implementation of the ECMAScript
> algorithms, which would use time converting the number to a string
> first.
You just did the first really crucial step in your new life: you
questionned The Book and tried to find a new reading to old texts.
Still long way to go but the step is done.
Here's some homework to do:
[1]
var hashObject = {};
var arrayObject = [];
/* Hashtable and Array are different objects
* with different structure and method/property sets:
*/
alert(hashObject instanceof Array); // false
alert(arrayObject instanceof Array); // true
/* But both Hashtable and Array are extending
* basic Object constructor, so whetever Object
* has, Hashtable and Array have too:
*/
alert(hashObject instanceof Object); // true
alert(arrayObject instanceof Object); // true
[2]
var tmp = 1;
alert(typeof tmp); // "number"
tmp = "";
alert(typeof tmp); // "string"
tmp = true;
alert(typeof tmp); // "boolean"
/* Does the above prove that there are no
* numbers, strings and booleans in JavaScript
* but only some amorphium "data holder"?
* Of course not! It just shows that JavaScript
* implements run-time typezation if needed.
*/
[3]
JavaScript was never written by ECMA standards.
ECMA standards are written by exploring pre-existing closed source
JavaScript engine (in Netscape Navigator). Whatever the team did not
see or did not understand properly went into papers as well as totally
correct descriptions (the right part still constitutes the total
majority of ECMA specs).
P.S. God damn! And I hopped to work closer on my jsFileManager this
week-end...