Are there any syntactic differences between ECMA-262 and ECMA-357?

I am writing an ECMA-262 based JavaScript parser. I would be interested to know how much I need to change to make it ECMA-357 compatible.

Are there any syntax differences?

+4
source share
1 answer

There are several syntax extensions. The most important are XML literals (see Sections 11.1.4 and 11.1.5):

var foo = <xml> foo </xml>; var bar = <> <tag attr={(1+2).toFixed(2)}/> {foo} </>; 

The above example shows a special case of an empty root tag and JavaScript expressions in XML code.

You also have some expressions that are not valid in ECMA-262 (see section 11.2):

 xml.@attr // get attribute attr xml.* // get all child elements xml.@ * // get all attributes xml..foo // get all <foo> tags xml..foo.(@id == 1) // filter <foo> tags by id attribute 

Namespaces exist (see section 11.1.2):

 xml.soap::foo // get <foo> child tags with namespace soap xml.@soap ::attr // get attribute with namespace soap 

There is a default namespace XML operator, which is a syntactically very unusual construct (see section 12.1):

 default xml namespace = new Namespace("http://foo/bar"); 

Finally, there is a for each .. in loop, which is similar to for .. in (see section 12.3):

 for each (var foo in xml) { } 

As far as I know, these are all differences in syntax, but you probably already got more than enough.

+3
source

Source: https://habr.com/ru/post/1396535/


All Articles