8.12.1 GetOwnProperty

2010-04-19

PropertyDescriptor [[GetOwnProperty]](P:String)

Create a PD based on the property of "this" object and return it.

String has a different implementation. See 15.5.5.2 for that.

Code: (Abstract Ecma)
function [[GetOwnProperty]](P){
if (!(P in O)) return undefined;
var D = new PropertyDescriptor(); // blank property descriptor
var X = ToPropertyDescriptor(O[P]); // "let x be O's own property named P" See O[P] as a Reference, not regular value
if (IsDataDescriptor(X)) {
D.[[Value]] = X.[[Value]];
D.[[Writable]] = X.[[Writable]];
} else { // X is an accessor property (? generic property?)
D.[[Get]] = X.[[Get]];
D.[[Set]] = X.[[Set]];
}
D.[[Enumerable]] = X.[[Enumerable]];
D.[[Configurable]] = X.[[Configurable]];
return D;
}

Note that ToPropertyDescriptor would need two arguments for Ecmascript since we can't pass along a Reference. If we gave it an object and the target property, it would be no problem.