Illegal defineProperty

by Yin Yong

HTML

<h3 class="err"></h3>

CSS

.err {color: red}

JavaScript

const origin = Object.create(null, {
  name: {
    value: 1,
    configurable: true
  }
});

const proxy = new Proxy(origin, {
  defineProperty: function(target, property, descriptor) {
    // should not always true
    return true;
  }
});

try {
  Reflect.defineProperty(origin, "name", {
    value: 2,
    // cannot be non-configurable on name
    configurable: false
  });
} catch (e) {
  document.querySelector('.err').innerText = e.message
}