es.reflect.prevent-extensions.js 659 B

12345678910111213141516171819
  1. var $ = require('../internals/export');
  2. var getBuiltIn = require('../internals/get-built-in');
  3. var anObject = require('../internals/an-object');
  4. var FREEZING = require('../internals/freezing');
  5. // `Reflect.preventExtensions` method
  6. // https://tc39.es/ecma262/#sec-reflect.preventextensions
  7. $({ target: 'Reflect', stat: true, sham: !FREEZING }, {
  8. preventExtensions: function preventExtensions(target) {
  9. anObject(target);
  10. try {
  11. var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions');
  12. if (objectPreventExtensions) objectPreventExtensions(target);
  13. return true;
  14. } catch (error) {
  15. return false;
  16. }
  17. }
  18. });