Reputation: 13856
Consider following JavaScript object
var planet = {
id: 1001,
Name: "Mars",
faction: {
factionId: 2,
notification: function () {
document.write("Mars notified");
}
},
cities: [
{ locationId: 15, name: "Gladius" },
{ city: "MyPlanet", geo: "universal" }
]
}
When trying to read planet.cities
in Chrome Debugger windows I see these additional items.
Are these part of JavaScript Runtime engine, and do different browsers handle them differently ?
Upvotes: 1
Views: 143
Reputation: 664256
Every JavaScript has a prototype object from which it inherits (EcmaScript §4.2.1). This is usually referred to as the "internal [[prototype]]
property" (EcmaScript §8.6.2). That FF and Chrome make it public as the non-standard (and deprecated) __proto__
property is implementation-specific.
These additional properties you see are on Object.prototype
(EcmaScript §15.2.4, MDN), from which all plain objects - and so your object literals - inherit. Again, the double-underscore-properties are implementation-specific and now deprecated by property descriptors (see Object.defineProperty
at MDN).
Upvotes: 3