Złe zachowanie w Google Chrome Object.defineProperty?
Próbuję utworzyć obiekt za pomocą setterów i getterów, a to jest mój kod:
var Player = function(height){
var _height = height;
Object.defineProperty(this, 'height', {
enumerable: false
, configurable: true
, writable: false
, get: function(){return _height;}
, set: function(val){_height = val;}
});
}
var myPlayer = new Player (10);
Nawet jeśliwritable
właściwość optionsProperty ma wartość false, pojawia się następujący błąd:
Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>
To samo dzieje się, gdywritable
jest oczywiście ustawione na true, ale błąd znika, jeśli usunęwritable
linia.
Czy robię coś źle, czy jest to błąd? Dzieje się tak w Google Chrome, wersja 30.0.1599.66