There's no error if you omit the parentheses around n. You may be
confusing that with something like (2).toString().
Right.
window.alert( "foo".length ); // 3
window.alert( 2.toString(2) ); // run-time error
window.alert( (2).toString(2) ); // 10
var n = 2; window.alert( n.toString(2) ); // 10
So different implicit up/down-casting for string literal, number
literal, number returning expression, identifier for number value. All
this still waits to be decently described for 14 years as well. Some
day maybe...
Anyway, that's not what I was talking about. In your example, there's a
reason why an object should be created: you want to access one of its
methods or properties. Even so, the object could potentially be
optimized away by a script engine, but at least the behavior is
described in terms of objects (yes, in the "mysterious" ECMAScript
specs), and the code looks as if there was an object. The same is not
true for the logical NOT operator. There's no mention of objects in the
specs, and the syntax doesn't suggest objects, either. You insist that
there's an Boolean object hidden in there somewhere, and that this
"correlates with the experimental results down to NN 2.02". How can you
experimentally test and confirm something which is never directly
accessible to you?
(unless you plan on building a Large Object Collider in Switzerland)
OK, I cannot "see" that temporary object wrapper just like I cannot
"see" that wrapper for "foo".length. Let's us say I do postulate its
existence - just like for the Higgs boson - as the only fully non-
contradictory explanation of the observed results. An LHC equivalent
could be to write yet another C++ program using say IActiveScript and
relevant interfaces. It is a ridiculous yet alas very common situation
to treat JavaScript implementation producers as some natural force of
the Universe unwillingly disclosing its secrets over time, efforts and
money consuming experiments...
:-|
That appears to be a quote from Microsoft's JScript documentation, not a
Netscape document.
It is a Netscape stuff, I am 99% sure. MSDN documentation may be not a
perfect source. It may be a terrible source by some criteria. But I do
not recall a case where a written "you'll get this" would be 95% wrong
to the actual JScript results on a span of 5 paragraphs in the row. I
say it happened because "nobody will read it anyway, so copy'n'paste
quickly from the original source".
Not for me. What I'm saying is that in order to evaluate a logical NOT,
there's no need to create a Boolean object, get its value, and destroy
it immediately afterwards. You claim that this is exactly what happens
in JavaScript. The SpiderMonkey source is open; show me the code.
Oh, alright - if you can dig it up in the NN2 sources, I'll accept that
as proof, too. Deal?
I cannot give you the final deal because I am not sure if it was ever
documented anywhere. It could be just a call from Eric Lippert (M$) to
Brendan Eich (N^) some day back in 1996
" - man, how do you treat that?
- eh... let me see... crap... it gives me that.
- will it give this in the future?
- eh... crap... crap... ok, it will be so from now on,
but let not say it to anyone explicitly, ok?
- sure man, so I'm coding it this way. have a good one.
- you too man... thanks.
"
Such standardization mechanics was very common for the 1995-1998
period and respectively such proof can be lost forever. So far I put a
daemon to query the Wayback Machine, but 1996 archives are very slow,
so even if anything was ever printed - it may take some long time.