Re: [whatwg/streams] Initialize ReadableByteStreamController.[[byobRequest]] to undefined (#990)

> I couldn't find where the behaviour of internal slots is specified, but I don't think they follow the prototype chain. I think reading from an uninitialised slot is implementation-specific behaviour. An implementation could crash if it wanted to.

I found [the following paragraph in the JavaScript spec](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-object-internal-methods-and-internal-slots):
> Internal slots correspond to internal state that is associated with objects and used by various ECMAScript specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific internal slot specification, such state may consist of values of any ECMAScript language type or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless specified otherwise, the initial value of an internal slot is the value **undefined**. Various algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no direct way to associate internal slots with an object.

Indeed, they do not follow the prototype chain, they must exist on the object itself. And they are implicitly initialized to `undefined`, so the explicit initialization is *technically speaking* not needed.

Still, I prefer being explicit, even if it only makes a difference for the reference implementation. 🙂

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/990#issuecomment-465114913

Received on Tuesday, 19 February 2019 12:46:01 UTC