Answers for "read only karma abstract"

0

read only karma abstract

const object1 = {};

// param 1: object up to property that is read only
// param 2: name of read-only property as a string
// param 3: The value to assign to the read only property and its configuration
Object.defineProperty(object1, 'property1', {
  value: 42,
  writable: false
});

object1.property1 = 77;
// throws an error in strict mode

console.log(object1.property1);
// expected output: 42
Posted by: Guest on May-01-2020

Browse Popular Code Answers by Language