Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Internal Property In ECMAScript is defined for?

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

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.

Does it mean that Internal properties defined by ECMAScript are not available for programming. They are used in the implementation of the javascript engine ?

like image 838
Prosunjit Biswas Avatar asked Jun 12 '12 18:06

Prosunjit Biswas


2 Answers

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.

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

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);
like image 164
seongjoo Avatar answered Nov 15 '22 20:11

seongjoo


Does it mean that Internal properties defined by ECMAScript are not available for programming. They are used in the implementation of the javascript engine ?

Yes. They are only for implementation purposes, and don't need "real names". You can read about that in #8.6.2 Object Internal Properties and Methods.

like image 44
Bergi Avatar answered Nov 15 '22 21:11

Bergi