Skip to main content

4 posts tagged with "Understanding ECMAScript"

View All Tags

Understanding the ECMAScript spec, part 3

· 12 min read
[Marja Hölttä](https://twitter.com/marjakh), speculative specification spectator

All episodes

In this episode, we’ll go deeper in the definition of the ECMAScript language and its syntax. If you’re not familiar with context-free grammars, now is a good time to check out the basics, since the spec uses context-free grammars to define the language. See the chapter about context free grammars in "Crafting Interpreters" for an approachable introduction or the Wikipedia page for a more mathematical definition.

Understanding the ECMAScript spec, part 2

· 11 min read
[Marja Hölttä](https://twitter.com/marjakh), speculative specification spectator

Let’s practice our awesome spec reading skills some more. If you haven’t had a look at the previous episode, now it’s a good time to do so!

All episodes

Ready for part 2?​

A fun way to get to know the spec is to start with a JavaScript feature we know is there, and find out how it’s specified.

Warning! This episode contains copy-pasted algorithms from the ECMAScript spec as of February 2020. They’ll eventually be out of date.

We know that properties are looked up in the prototype chain: if an object doesn’t have the property we’re trying to read, we walk up the prototype chain until we find it (or find an object which no longer has a prototype).

For example:

const o1 = { foo: 99 };
const o2 = {};
Object.setPrototypeOf(o2, o1);
o2.foo;
// → 99

Where’s the prototype walk defined?​

Let’s try to find out where this behavior is defined. A good place to start is a list of Object Internal Methods.

There’s both [[GetOwnProperty]] and [[Get]] — we’re interested in the version that isn’t restricted to own properties, so we’ll go with [[Get]].

Unfortunately, the Property Descriptor specification type also has a field called [[Get]], so while browsing the spec for [[Get]], we need to carefully distinguish between the two independent usages.

Understanding the ECMAScript spec, part 1

· 9 min read
[Marja Hölttä](https://twitter.com/marjakh), speculative specification spectator

All episodes

In this article, we take a simple function in the spec and try to understand the notation. Let’s go!

Preface​

Even if you know JavaScript, reading its language specification, ECMAScript Language specification, or the ECMAScript spec for short, can be pretty daunting. At least that’s how I felt when I started reading it for the first time.