ES5 added a number of methods to Object
, which seem to break the semantic consistency of JavaScript.
For instance, prior to this extension, the JavaScript API always revolved around operarting on the object itself;
var arrayLength = [].length;
var firstPosInString = "foo".indexOf("o");
... where as the new Object methods are like;
var obj = { };
Object.defineProperty(obj, {
value: 'a',
writable: false
});
... when the following would have been much more conformative:
var obj = { };
obj.defineProperty({
value: 'a',
writable: false
});
Can anyone cool my curiosity as to why this is? Is there any code snippets that this would break? Are there any public discussions made by the standards committee as to why they chose this approach?