July 24, 2020
let arr = [1,2,3,4];
let arr2 = [5,6,7,8];
let arr3 = [1,2,3,4];
let obj = {arr, arr2};
let ws = new WeakSet();
ws.add(arr); // 배열 삽입
ws.add(arr2); // 배열 삽입
ws.add(obj); // 객체 삽입
ws.delete(arr2) // arr2를 지워주세요
ws.add(111); // invalid type error
ws.add('111'); // invalid type error
ws.add(null); // invalid type error
ws.add(function(){}); // 함수객체 삽입
arr = null;
console.log(ws) // { 0 : obj, 1 : function..., 2 : arr }
console.log(ws.has(arr)); // false