gpt4 book ai didi

javascript - 无论是否可扩展,JavaScript 对象存储在哪里?

转载 作者:行者123 更新时间:2023-11-30 11:50:15 25 4
gpt4 key购买 nike

如问题中所述,在 JavaScript 中,无论是否可扩展,对象存储在哪里?

属性值可以通过Object.isExtensible()访问,但是这些信息存储在哪里?

谢谢!

最佳答案

在其[[Extensible]] internal slot ,它不能直接从您的代码访问(但当然可以通过 Object.isExtensibleReflect.isExtensible 访问)。

来自链接:

Every ordinary object has a Boolean-valued [[Extensible]] internal slot that controls whether or not properties may be added to the object. If the value of the [[Extensible]] internal slot is false then additional properties may not be added to the object. In addition, if [[Extensible]] is false the value of the [[Prototype]] internal slot of the object may not be modified. Once the value of an object's [[Extensible]] internal slot has been set to false it may not be subsequently changed to true.

内部槽有点像属性,但不是继承的,也不能(直接)从程序代码访问。来自 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.

关于javascript - 无论是否可扩展,JavaScript 对象存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39688615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com