CanBeHeldWeakly.js 389 B

12345678910111213141516
  1. 'use strict';
  2. var KeyForSymbol = require('./KeyForSymbol');
  3. var Type = require('./Type');
  4. // https://262.ecma-international.org/14.0/#sec-canbeheldweakly
  5. module.exports = function CanBeHeldWeakly(v) {
  6. if (Type(v) === 'Object') {
  7. return true; // step 1
  8. }
  9. if (typeof v === 'symbol' && typeof KeyForSymbol(v) === 'undefined') {
  10. return true; // step 2
  11. }
  12. return false; // step 3
  13. };