[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Errors/Read-only [Back]  [Original]

TypeError: "x" is read-only( : "x" ) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

TypeError: "x" is read-only( : "x" )

TypeError:           (Edge)
TypeError: "x"     (Firefox)
TypeError: 0     (Firefox)
TypeError:        "x"  #<> (Chrome)
TypeError:        '0' [ ] (Chrome)

In this article

TypeError

?

. ( , .)

. .

, Object.defineProperty() Object.freeze().

js
"use strict";
var obj = Object.freeze({ name: "Elsa", score: 157 });
obj.score = 0; // TypeError

("use strict");
Object.defineProperty(this, "LUNG_COUNT", { value: 2, writable: false });
LUNG_COUNT = 3; // TypeError

("use strict");
var frozenArray = Object.freeze([0, 1, 2]);
frozenArray[0]++; // TypeError

JavaScript , . , .

js
"use strict";
Math.PI = 4; // TypeError

, .

undefined , "undefined is not a function:

js
"use strict";
undefined = function () {}; // TypeError: "undefined"    

js
"use strict";
var obj = Object.freeze({ name: "Score", points: 157 });
obj = { name: obj.name, points: 0 }; //      

("use strict");
var LUNG_COUNT = 2; // "var` ,       
LUNG_COUNT = 3; // ok ( , )


Web Proxy Viewer  |  New URL  |  Original Page