Utwórz JavaScript tylko do odczytu
Object.prototype.makeReadonly = function(property)
{
var propValue = this['property'];
Object.defineProperty(this, property, {
value: propValue,
writable: false,
});
};
var obj = {
testStr: "Hello World!",
};
obj.makeReadonly('testStr');
obj.testStr = "hello world";
console.log(obj.testStr); // outputs "Hello World!"
Tilted Turtle