ECMAScript中定义的对象的可变性在哪里? [英] Where is the mutability of Objects defined in ECMAScript?

查看:95
本文介绍了ECMAScript中定义的对象的可变性在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题中关于JavaScript函数中参数的传递,我们了解到一切都是通过JavaScript中的值传递的.

In this question about the passing of arguments in JavaScript functions, we learn that everything is passed by value in JavaScript.

Mozilla文档中,提到了基本类型是不可变的,而对象是不可变的.尽管我来自过程性和结构化程序设计学校,但我还是能够快速掌握这些概念.

In Mozilla documents, it is mentioned that the primitive types are immutable, and objects are. Although I came from the procedural and structured programming school, I was able to quickly pick up the concepts.

在ECMAScript标准中,定义为对象在逻辑上是属性的集合".该标准还定义了如何比较对象,但是忽略了当对象通过GetValue()伪函数(将引用转换为值)时发生的情况.

In the ECMAScript standard, it is defined that "An Object is 'logically' a collection of properties". The standard also defines how objects may be compared, but left out on what happens when an object goes through the GetValue() pseudo-function that converts references into values.

因此,我给出了

So, I gave an answer in the question basically saying that this area had been left undefined.

我觉得未定义"的意思是,从哲学上讲,这还不是很清楚,对象的价值是什么.该标准已经过几次修订,并且其规模还在不断增加.

I feel that by "left undefined", I meant, it wasn't philosophically thoroughly clear, what the value of an Object is. The standard had gone through a few revisions, and its size is ever increasing.

简而言之,对象是一个集合,但是集合的值是多少?它的内容是否构成?还是个性?还是我错过了一些重要的文章?

In short, an object is a collection, but what is the value of the collection? Is it the makeup of its content? Or is it individuality? Or have I been missing out on some important texts?

推荐答案

在ECMAScript规范中,每个对象都定义为具有某些内部方法",其中一些(例如[[DefineOwnProperty]]和[[Put] ])可以更改对象的状态.最终,对象的可变性是通过使用这种内部方法来定义的.

In the ECMAScript spec, every object is defined to have certain 'internal methods', some of which (e.g., [[DefineOwnProperty]] and [[Put]]) can change the state of the object. Ultimately, the mutability of objects is defined via the use of such internal methods.

这篇关于ECMAScript中定义的对象的可变性在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆