Export (0) Print
Expand All
Expand Minimize

JS5040: Assignment to read-only field or property

The code assigns a value to a read-only identifier. This is not allowed because code cannot write to read-only identifiers.

The const statement defines a read-only field or a constant. A function get statement without a matching function set statement defines a read-only property.

To correct this error

  1. Make sure the code does not assign values to read-only identifiers.

  2. Define the field or variable with the var statement to make it assignable.

  3. Add a matching function set statement to the property to make it assignable.

Community Additions

ADD
Show:
© 2014 Microsoft