Home > Net >  Is there an official implementation of ECMAScript Language Specification?
Is there an official implementation of ECMAScript Language Specification?

Time:06-12

I'm interesting in how JS source code works and seems that I should to use ECMAScript® Language Specification. In my case I tried to write my own implemetetion of Function.prototype.call

Function.prototype._call = function (thisArg = {}, ...arg) {
  // 1. Let func be the this value.
  let func = this
  // 2. If IsCallable(func) is false, throw a TypeError exception.
  if (typeof func !== 'function') {
    throw new TypeError(this   "isn't callable")
  }
  // 3. Perform PrepareForTailCall().
  thisArg.func = func
  // 4. Return ? Call(func, thisArg, args).
  return thisArg.func(...arg)
}

It works, but I'm not sure that my implementation is correct and would like to compare it with the "official" implementation. Where may I find code references for ECMAScript examples? Thank you!

CodePudding user response:

No, there is no reference implementation for ECMAScript, the definitive authoriative source is the specification itself - see also its Conformance section. It is accompanied by the official Test262: ECMAScript Test Suite

The closest to what you are looking for would be the Engine 262 project.

CodePudding user response:

Is there an official implementation of ECMAScript Language Specification?

Such an implementation is known as a reference implementation, rather than an "official" implementation, as surely every conforming and certified (is that even a thing for ECMAScript?) implementation is "official".

But yes, there is - but as far as I can tell, only ECMAScript 4 from 2007 has (had?) an actual reference implementation which was available to download from the ECMAScript.org website.


https://lambda-the-ultimate.org/node/2289

ECMAScript Edition 4 Reference Implementation

The first pre-release of the reference implementation of ECMAScript Edition 4 (a.k.a. JavaScript 2) is now available. We've created a new web site for information about the ECMAScript specification and reference implementation. You can download source and binary forms of the reference implementation.


  • Related