- A non-writable property cannot be changed with an assignment operator (
=
,*=
,**=
,/=
,+=
,-=
) - To define a non-writeable property on an object use
Object.defineProperty()
and setwritable
to false:var obj = {} // writable is also false by default Object.defineProperty(obj, 'a', { value: 2, writable: false });
Non-writeable properties
February 15, 2022