gpt4 book ai didi

javascript - 为什么不将 "9007199254740991"视为整数索引?

转载 作者:行者123 更新时间:2023-12-04 15:17:57 26 4
gpt4 key购买 nike

根据the specification , 一个字符串值的属性键,其数值为 2 ** 53 - 1必须被视为整数索引。
根据the specification , [[OwnPropertyKeys]] internal 方法必须枚举属性键,它是一个整数索引,按数字升序排列。
根据the specification , Reflect.ownKeys调用[[OwnPropertyKeys]]内部方法。

因此,如果我的理解正确,以下代码应按数字升序显示属性键(即 ["9007199254740990", "9007199254740991"] )。
然而,所有现有的实现都以属性创建的时间升序显示属性键(即 ["9007199254740991", "9007199254740990"] )。

console.log(Reflect.ownKeys({"9007199254740991": null, "9007199254740990": null}));


我的错误是什么?

最佳答案

The specification of the [[OwnPropertyKeys]] internal method in ECMAScript 2017 (和 in 2018 )与所有主要 JavaScript 引擎的实际行为不匹配,因此在 ECMAScript 2019 中,the specification has been fixed .
the discussion on GitHub .

关于javascript - 为什么不将 "9007199254740991"视为整数索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49147172/

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