es.reflect.prevent-extensions.js 673 B

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