ECMAScript中定义的内部属性是什么? [英] What Internal Property In ECMAScript is defined for?

查看:160
本文介绍了ECMAScript中定义的内部属性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ECMAScript中内部属性的定义是什么?该规范是什么意思

What the Internal Property in ECMAScript is defined for ? What does the spec mean by


此规范使用各种内部属性来定义对象值的
语义。这些内部属性是不属于
ECMAScript语言的一部分。它们由本规范定义
纯粹用于说明目的。

This specification uses various internal properties to define the semantics of object values.These internal properties are not part of the ECMAScript language. They are defined by this specification purely for expository purposes.

这是否意味着 ECMAScript定义的内部属性无法进行编程。它们用于实现javascript引擎

推荐答案

内部属性定义代码执行时的行为,但无法通过代码访问。 ECMAScript为JavaScript中的对象定义了许多内部属性。内部属性由双平方括号表示。

Internal properties define the behavior of code as it executes but are not accessible via code. ECMAScript defines many internal properties for objects in JavaScript. Internal properties are indicated by double-square-bracket notation.

例如,JavaScript函数是一个对象,它具有[[call]]属性。 [[call]]属性是函数的唯一属性。

For example, JavaScript function is an object and it has [[call]] property. [[call]] property is unique to function.

另一个内部属性示例是[[prototype]]属性。此属性是指向实例正在使用的原型对象的指针。由于无法通过代码访问内部属性,因此对象实例化无法访问原型,而其属性对对象都可用。您可以通过对对象使用Object.getPrototypeOf()方法获取[[prototype]]属性的值。

Another internal property example is [[prototype]] property. This property is a pointer pointing back to the prototype object that the instance is using. Since internal property cannot be accessed via code, an object instantiation cannot access to the prototype while its properties are all available to the object. You can get the value of [[prototype]] property by using Object.getPrototypeOf() method on an object.

var obj = new Object();
var prototype = Object.getPrototypeOf(obj);
console.log(prototype == Object.prototype);

这篇关于ECMAScript中定义的内部属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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