2 个回答

internal slot

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.

Internal methods and internal slots are identified within this specification using names enclosed in double square brackets [[ ]].

ECMA262 为了维护对象的内部状态引入的一些“内置槽”。他们不是对象属性,程序员无法直接操作。

这是 ECMAScript-262 中规定的 内置属性internal property)。

这些属性无法在 JS 代码中访问。

你可以将它近似的理解为其他面向对象语言中的私有属性,外部无法访问。

相关定义可以参考该规范的第 8.6.2 小节:http://www.ecma-international...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题