How do i read only value attr?

I want make value attribute to read-only and i do these code but not work ??

Do everybody know it ?

const obj = {
  name: "karl"
}
const origName = obj.name;
Object.defineProperty(obj, 'name', {
  enumerable: false,
  configurable: false,
  get() {
    return origName + 2;
  }
});

69 thoughts on “How do i read only value attr?”

Leave a Comment