1 2 3 4 5 6 7 8 9 10 11
// feature probe for 'WeakSet' try { if (typeof WeakSet !== 'function') throw new Error('WeakSet missing'); const ws = new WeakSet(); const k = {}; ws.add(k); if (!ws.has(k)) throw new Error('WeakSet failed'); console.log('OK'); } catch (e) { console.log('NO'); }