14

What would happen if I start to define my script tags as ECMA? Will it execute to a different standard?

Does anyone actually use ECMA script instead of straight up Javascript...?

Michael Gaskill
  • 7,913
  • 10
  • 38
  • 43
Exitos
  • 29,230
  • 38
  • 123
  • 178
  • 2
    Not sure if it is a duplicate, but this was asked earlier today: http://stackoverflow.com/questions/4269150/what-is-ecmascript Here's a question with almost the exact same title: http://stackoverflow.com/questions/912479/what-is-the-difference-between-javascript-and-ecmascript – user113716 Nov 24 '10 at 21:28
  • Asked and answered: http://stackoverflow.com/questions/912479/what-is-the-difference-between-javascript-and-ecmascript – Alexx Roche Jul 15 '13 at 18:09
  • Here I found a good link that explain the difference between JavaScript and ECMAScript: https://medium.freecodecamp.org/whats-the-difference-between-javascript-and-ecmascript-cba48c73a2b5 – S. Mayol Nov 09 '17 at 04:04

2 Answers2

29

ECMAScript is a standard. JavaScript is an implementation of that standard (edition 3 of that standard to be more exact).

Other implementations of ECMAScript are ActionScript and JScript.

Also note that there isn't one JavaScript. Each JavaScript engine may implement its own version of the language as long as it meets the ECMAScript requirements. This means that browsers (JS engines) may have additional functionality, but they all must have the base ECMAScript functionality.

And now, to answer your question, according to RFC 4329, if the media type is set to application/ecmascript, rather than application/javascript, it must adhere to a stricter standard.

This document defines equivalent processing requirements for the types text/javascript, text/ecmascript, and application/javascript. Use of and support for the media type application/ecmascript is considerably less widespread than for other media types defined in this document. Using that to its advantage, this document defines stricter processing rules for this type to foster more interoperable processing.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Alin Purcaru
  • 43,655
  • 12
  • 77
  • 90
  • Don't use `application/*` as script type, IE will choke on that. – Marcel Korpel Nov 24 '10 at 21:49
  • Good point, but I wanted to use `application/*`, rather than `text/*`, to conform to the RFC recommendations. The arguments still apply if you replace with `text/*`. – Alin Purcaru Nov 24 '10 at 21:50
  • I'm not following exactly. Is it sort of like saying that by standard you mean syntax and common set of features ( like an interface in java ) , and maybe one implementation could allow additional things like say, lambdas whereas another implementation may not ? – Abhinav Vishak Oct 05 '17 at 21:37
  • @AbhinavVishak What you stated is correct. You can look at it this way... ES:JS ~ Interface:Implementation. Or at least this is how it should be, ideally. In practice though, things are a bit more complicated and there are a lot of articles available online for those who want to understand more. As a note, here are a couple of ways in which ES differs from an Interface. For one, nobody is enforcing that an ES implementation actually respects the standard. And second ES, at least in its most recent incarnation has become a living standard. It's modular and has quick iterations. – Alin Purcaru Oct 06 '17 at 08:37
  • Here I found a good link that explain the difference between JavaScript and ECMAScript: https://medium.freecodecamp.org/whats-the-difference-between-javascript-and-ecmascript-cba48c73a2b5 – S. Mayol Nov 09 '17 at 04:05
3

ECMAScript is a programming language standard, like lisp. Javascript is an implementation of such, along with non-ECMAScript features like the DOM. ActionScript(for Flash) is another one. Just like writing in "lisp" means writing in some dialect like Common Lisp or Scheme, actually writing straight-up ECMAScript might not only be pointless, but unusable in the dialects(although I think ActionScript 3 and recent JavaScript apply the whole ECMAScript standard).

Saqib Omer
  • 5,387
  • 7
  • 50
  • 71
rtpg
  • 2,419
  • 1
  • 18
  • 31