JavaScript ECMAScript definitions

M

manno

Hi all,

more or less just out of curiosity...

I had a short 'discussion' about JavaScript in different borwsers. The
other guy said that there's differeces in JavaScript accross browsers (I
assumed he meant apart from versions) "because there's different
functions".
I didn't agree because I think that's because of different DOM's. I know
that for example IE 5.0 (or 5.5?) does not support array.push() (and a
lot more), but isn't that just sloppy implementation or simply using
different versions of the language?

Is it safe to say that one version of JavaScript should be the same
everywhere except for DOM differences?

Is JavaScript ECMA-262 with browserspecific elements?

Thanks in advance,

Manno
 
M

Martin Honnen

manno wrote:

I had a short 'discussion' about JavaScript in different borwsers. The
other guy said that there's differeces in JavaScript accross browsers (I
assumed he meant apart from versions) "because there's different
functions".
I didn't agree because I think that's because of different DOM's. I know
that for example IE 5.0 (or 5.5?) does not support array.push() (and a
lot more), but isn't that just sloppy implementation or simply using
different versions of the language?

Well, array.push is not part of the DOM at all, its a method of the core
object Array.

Is JavaScript ECMA-262 with browserspecific elements?

It depends on whom you ask and perhaps it also depends when you ask or
asked someone.
With its introduction in the Netscape 2.02 browser there was only one
implementation of the language and that was in a browser environment but
there was no ECMAScript standard at all. Later Netscape used its
JavaScript engine also on the server and documented both client-side
JavaScript and server-side JavaScript "versions" which consisted of core
objects specified in ECMAScript and host environment specific objects
like window, document in client-side JavaScript and server specific
objects in server-side JavaScript.
By now Netscape respectively Mozilla has two open-source JavaScript
engines, one called Spidermonkey implemented in C, the other called
Rhino imlemented in Java, and there are many different applications that
use those engines. So you can have JavaScript scripting in many
environments, not only browser specific ones.
And the MS JScript scripting engine can also be embedded in many
different environments, in the IE browser but as well in ASP pages as in
Windows Script host.
 
M

manno

Martin said:
Well, array.push is not part of the DOM at all, its a method of the core
object Array.

I know the array object's functions are no part of any DOM, I was trying
to go along in the arguments of the guy I argued with. But to go
_against_ his argument, is it sloppy implementation or just another
version of JavaScript that IE 5 version uses?
So you can have JavaScript scripting in many
environments, not only browser specific ones.

That was more or less why I asked, Flash (and the new Director MX 2004)
support "ECMAScript-compliant JavaScript syntax", I was wondering if
this actually could be said of browsers too: "Firefox supports
ECMAScript-compliant JavaScript syntax".

All with a different 'DOM' ofcourse.

Thanks
Manno
 
M

Martin Honnen

manno said:
I know the array object's functions are no part of any DOM, I was trying
to go along in the arguments of the guy I argued with. But to go
_against_ his argument, is it sloppy implementation or just another
version of JavaScript that IE 5 version uses?

MS calls its implementation of JavaScript/ECMAScript JScript. I think
IE5 came with JScript 5 and whether at that time ECMAScript edition 3
was already out I don't remember exactly, I think Windows 98 already
featured IE5 while the ECMAScript edition 3 standard came out at the end
of 1999 thus MS was probably not sloppy in implementing that standard
but rather focussing on other things and waiting for ECMAScript edition
3 to be finalized.
 
L

Lasse Reichstein Nielsen

manno said:
I know the array object's functions are no part of any DOM, I was
trying to go along in the arguments of the guy I argued with. But to
go _against_ his argument, is it sloppy implementation or just another
version of JavaScript that IE 5 version uses?

It's JScript, not Javascript. There is no standard for Javascript
(except perhaps Netscape's documentation for JavaScript).
What there is, is ECMAScript, as specified by ECMA 262. It is currently
at version 3. Array.prototype.push was not in ECMA 262 v2, but is in
v3. It is likely that the versions of JScript shipped with IE 5 was
based on ECMA 262 v2.
That was more or less why I asked, Flash (and the new Director MX
2004) support "ECMAScript-compliant JavaScript syntax", I was
wondering if this actually could be said of browsers too: "Firefox
supports ECMAScript-compliant JavaScript syntax".

Sure. And it is just a way of saying "supports ECMAScript" that still
makes sense for people who think it's all called Javascript.

/L
 
J

Java script Dude

manno said:
Hi all,

more or less just out of curiosity...

I had a short 'discussion' about JavaScript in different borwsers. The
other guy said that there's differeces in JavaScript accross browsers (I
assumed he meant apart from versions) "because there's different
functions".
I didn't agree because I think that's because of different DOM's. I know
that for example IE 5.0 (or 5.5?) does not support array.push() (and a
lot more), but isn't that just sloppy implementation or simply using
different versions of the language?

Is it safe to say that one version of JavaScript should be the same
everywhere except for DOM differences?

Is JavaScript ECMA-262 with browserspecific elements?

Thanks in advance,

Manno

IE 5.5+ supports array.push(), IE Mac does not.
 
M

Martin Honnen

Dr said:
JRS: In article <[email protected]>, seen in



Windows 98 was released in the UK (on 1998-07-01, IIRC) with MSIE 4
4.72.3110 SP1 using JScript 3.1.2124 or so it seems.

Somehow I still associate some IE5 release with some Windows 98 release,
I think there is also Windows 98 second edition (Windows 98 2 ED), maybe
that came with IE5 and was still out before the ECMAScript edition 3
specification.
 
T

Thomas 'PointedEars' Lahn

manno said:
About the JScript in IE. I was aware of JScript, but thought it was
totally seperate from JavaScript [...]

It is. Nevertheless both JavaScript and JScript are ECMAScript
implementations (actually, JScript claims to be one while JavaScript is
one), so they share common objects and methods. However, since objects and
methods may be (and actually are) implemented differently. ECMAScript is a
language to be implemented and the language specification makes clear where
a conforming implementation has certain liberties.
But if IE calls it JScript and doesn't run JavaScript, what happens with
the type and language attribute of the script tag if set to
"text/JavaScript" and "JavaScript{version}"?

It executes it anyway, using an engine that supports both JScript and VBScript.


PointedEars
 
J

Jim Ley

manno said:
About the JScript in IE. I was aware of JScript, but thought it was
totally seperate from JavaScript [...]

It is. Nevertheless both JavaScript and JScript are ECMAScript
implementations (actually, JScript claims to be one while JavaScript is
one),

Sorry, why do you claim a distinction, the number of non-conformance
to the specs is minimal in both implementations, but both
implementations have them. JavaScript is certainly not a conformant
implementation any more than JScript is.
It executes it anyway, using an engine that supports both JScript and VBScript.

The core Script Engine doesn't support both JScript and VBScript,
there's a host engine which supports any ActiveScripting language, and
there's seperate implementations of JScript and VBScript - delete
vbscript.dll from your windows box and JScript still works fine.

Jim.
 
T

Thomas 'PointedEars' Lahn

Jim said:
Thomas 'PointedEars' Lahn said:
manno said:
About the JScript in IE. I was aware of JScript, but thought it was
totally seperate from JavaScript [...]

It is. Nevertheless both JavaScript and JScript are ECMAScript
implementations (actually, JScript claims to be one while JavaScript is
one),

Sorry, why do you claim a distinction, the number of non-conformance to
the specs is minimal in both implementations, but both implementations
have them. JavaScript is certainly not a conformant implementation any
more than JScript is.

Two obvious reasons: For example, I know of versions of JScript which yield
a script error even if one only tests *if* a property exists. In JScript,
only a function statement with mandatory identifier is specified; the
"function" operator (allowing for anonymous functions) as defined in
JavaScript, works anyway. I do not know of similar flaws in JavaScript.
The core Script Engine doesn't support both JScript and VBScript, there's
a host engine which supports any ActiveScripting language, and there's
seperate implementations of JScript and VBScript - delete vbscript.dll
from your windows box and JScript still works fine.

ACK, thanks.


PointedEars
 
J

Jim Ley

Jim Ley wrote:
Two obvious reasons: For example, I know of versions of JScript which yield
a script error even if one only tests *if* a property exists.

Sure, but I know of the same in SpiderMonkey impls.
In JScript,
only a function statement with mandatory identifier is specified; the
"function" operator (allowing for anonymous functions) as defined in
JavaScript, works anyway.

Sorry, I'm missing what you're trying to say here? it's something
defined in _JavaScript_ that you're saying isn't in JScript and that's
a reason to say JScript isn't ECMAScript conformant?
I do not know of similar flaws in JavaScript.

Just yesterday there was a discussion on the non-conformance of \b in
RegExps - it was agreed it was a positive non-conformance, but it's
still not conformant. There are also others.

Jim.
 
T

Thomas 'PointedEars' Lahn

Jim said:
Sure, but I know of the same in SpiderMonkey impls.

And that is a *serious* violation of the ECMAScript specification.
Tests must be possible, even if they are unsuccessful at last.
Sorry, I'm missing what you're trying to say here? it's something
defined in _JavaScript_ that you're saying isn't in JScript and that's a
reason to say JScript isn't ECMAScript conformant?

No anonymous functions with "function" keyword and without identifier
are specified in ECMAScript. JavaScript calls this a "function"
operator. JScript does not specify this at all, yet it works.


PointedEars
 
R

Randy Webb

Thomas said:
And that is a *serious* violation of the ECMAScript specification.

ECMA is a recommendation and nothing more. It reminds me of the W3C.
Yes, its nice to "comply", but it is not *required*. I would rather
write/produce code that *works* than code that *complies* but doesn't work.
 
J

Jim Ley

Well sure, PIE isn't conformant - hardly news there. (the error also
only manifests itself with host objects, so it's hardly deadly in the
real world, and it doesn't happen on real browsers.)
ECMA is a recommendation and nothing more. It reminds me of the W3C.

No, unlike the W3C stuff, ECMAScript is a proper International
standard. again there's good reasons for not worrying about \b in
regexps or \ at the end of line or the other minor non-conformances
though, and the various ES impl's are very much more conformant than
anything else we get to play with.

(I still don't understand Thomas's point about function literals, all
I can see is a complaint against JScript's documentation since "it
works".

Jim.
 
L

Lasse Reichstein Nielsen

Thomas 'PointedEars' Lahn said:
No anonymous functions with "function" keyword and without identifier
are specified in ECMAScript. JavaScript calls this a "function"
operator. JScript does not specify this at all, yet it works.

You are distinguishing between the documentation of JScript and the
actual implementation. The implementation is ECMAScript conformant.
The documentation is flawed.

/L
 
T

Thomas 'PointedEars' Lahn

Lasse said:
You are distinguishing between the documentation of JScript and the
actual implementation.

Yes, I do.
The implementation is ECMAScript conformant.

It is not, but the point is not the documentation issue but, for example,
the property test issue. I am yet too see something specified that badly
b0rken in JavaScript.
The documentation is flawed.

Additionally, since it omits important features like this but ibid
it is stated that JScript is an ECMAScript conforming implementation.


PointedEars
 
L

Lasse Reichstein Nielsen

Thomas 'PointedEars' Lahn said:
It is not, but the point is not the documentation issue but, for example,
the property test issue. I am yet too see something specified that badly
b0rken in JavaScript.

Which test is that? If it is on a host object, then there is no
guarantee that it should work.
Additionally, since it omits important features like this but ibid
it is stated that JScript is an ECMAScript conforming implementation.

Well, what's the problem then? That says that function expressions
work, even if it is not explicitly mentioned anywhere else in the
JScript documentation. :)

/L
 
T

Thomas 'PointedEars' Lahn

Lasse said:
Which test is that?

I have never experienced such a behavior, only read of it (the
discussion was about the problems of a generic DHTML library):

,-<[email protected]>
|
| [...]
| Rette mal bei IE4 auf dem Mac blind eine existierende Fenstereigenschaft,
| der nicht zuvor ein Wert zugewiesen wurde. Dein Rettungsversuch endet mit
| einer fehlermeldung. Du kannst auch nicht prüfen, ob es etwas zu retten
| gibt. Allein die Prüfung verursacht schon einen fehler, wenn es nichts zu
| retten gibt. Bei einem normalen Browser würdest Du einen eventiellen
| error-Handler retten, Deinen eigenen konnektieren und dann innerhalb
| Deines eigenen den geretteten aufrufen. Bei IE4 auf dem Mac geht das
| nicht, wenn es nicht schon einen error-Handler gibt. Genau das aber kannst
| Du nicht feststellen, ohne einen Fehler zu riskieren. Bugs dieser Art gibt
| es massenhaft. [...]

Translation:

| [...]
| With IE4 on the Mac, try to make a backup of an existing property of [a]
| window that has not been assigned a value previously. Your trial results
| in an error message. You cannot even check if there is something to back
| up. The check itself results in an error if there is nothing to back up.
| In a normal browser you would back up a possible error handler, connect
| your own and then call the backed up one from yours. With IE4 on the
| Mac this is impossible if there is not already an error handler. But
| you cannot determine exactly this without risking an error. There are
| a lot of bugs like this. [...]
If it is on a host object, then there is no guarantee that it should work.

Wrong. Even host objects, if they provide an ECMAScript interface, need to
exhibit ECMAScript compliant behavior. That is, for example, the mere test
for a property must not result in a runtime error.


PointedEars
 
L

Lasse Reichstein Nielsen

Thomas 'PointedEars' Lahn said:
Translation:

| [...]
| With IE4 on the Mac,

(I am not sure what "an existing property ... that has not been
assigne a value previously" is ... how do we know it exists if
we haven't created it, and can't read it?).

It's highly probable that a browser released in January 1998 doesn't
implement ECMAScript v3, which was finalized in December 1999.
In the same way, Netscape's JavaScript 1.2 wasn't ECMAScript compliant
either.

However, current versions of JavaScript and JScript are on the same
level of ECMAScript conformance - almost perfect.

Wrong. Even host objects, if they provide an ECMAScript interface, need to
exhibit ECMAScript compliant behavior. That is, for example, the mere test
for a property must not result in a runtime error.

No. ECMA 262 v3, section 8.6.2 says:
---
Host objects may implement these internal methods with any
implementation-dependent behaviour, or it may be that a host object
implements only some internal methods and not others.
---
where "these internal methods" includes [[Get]]. If [[Get]] is undefined,
then merely testing for a property will give a runtime error.

With host objects, all bets are off.
/L
 
T

Thomas 'PointedEars' Lahn

Lasse said:
Thomas 'PointedEars' Lahn said:
Translation:
| [...]
| With IE4 on the Mac,

(I am not sure what "an existing property ... that has not been assigne a
value previously" is ... how do we know it exists if we haven't created
it, and can't read it?).

We can write to it and see an effect, I suppose.
It's highly probable that a browser released in January 1998 doesn't
implement ECMAScript v3, which was finalized in December 1999. In the
same way, Netscape's JavaScript 1.2 wasn't ECMAScript compliant either.

IE for Mac is using JScript which has always claimed to be ECMAScript compliant.
However, current versions of JavaScript and JScript are on the same level
of ECMAScript conformance - almost perfect.

Well, I had wo workaround the same b0rken behavior with host objects in the
current IE (JScript 5.6.x).
Wrong. Even host objects, if they provide an ECMAScript interface,
need to exhibit ECMAScript compliant behavior. That is, for example,
the mere test for a property must not result in a runtime error.

[...] If [[Get]] is undefined, then merely testing for a property will
give a runtime error.

Not necessarily. AIUI the "typeof" operator does not call [[Get]] always:

| 8.7 The Reference Type
| [...]
| GetBase(V). Returns the base object component of the reference V.
| GetPropertyName(V). Returns the property name component of the
| reference V.

| 11.4.3 The typeof Operator
|
| The production UnaryExpression : typeof UnaryExpression is evaluated as
| follows:
|
| 1. Evaluate UnaryExpression.
| 2. If Type(Result(1)) is not Reference, go to step 4.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| 3. If GetBase(Result(1)) is null, return "undefined".
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| 4. Call GetValue(Result(1)).
^^^^^^^^^^^^^^^^^^^^^^^^
| 5. Return a string determined by Type(Result(4)) according to the
| following table:
| [...]

| 8.7.1 GetValue (V)
|
| 1. If Type(V) is not Reference, return V.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| 2. Call GetBase(V).
| 3. If Result(2) is null, throw a ReferenceError exception.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| 4. Call the [[Get]] method of Result(2), passing GetPropertyName(V)
| for the property name.
| 5. Return Result(4).

But that operator is available since the first version of JScript:
With host objects, all bets are off.

No, they are not, at least they *should not*.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top