JavaScript: Basics

What are “Internal Slots” and “Internal Methods” in JavaScript?

ECMAScript 2015 specification came up with the idea of internal slots and internal methods that specify the internals properties and methods of the object not exposed to runtime.

Uday Hiwarale
JsPoint
Published in
5 min readAug 31, 2020

--

(source: unsplash.com)

The 6.1.7.2 section of the ECMAScript 2015 specification talks about some weird internal properties and internal methods objects (descendants of Object) can have. These properties or methods are implemented by the JavaScript engine but they are abstracted away from the runtime, hence you won’t be able to access them on the objects like normal properties.

These are represented by the [[<name>]] notation in the ECMAScript specification where name is the name of the internal property or internal method. The internal property is called an internal slot and it contains a value associated with that object to represent some state of the object.

Let’s take a quick example. The [[GetPrototypeOf]] internal method is implemented by all the objects and its job is to return the prototype of the object. When you execute Reflect.getPrototypeOf(obj) method with obj being the object whose prototype needs to be inspected, JavaScript engine calls the…

--

--