Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript WeakMaps Are Not iterable

const weakMap = new WeakMap();
console.log(weakMap); // WeakMap {} 

let obj = {};

// adding object (element) to WeakMap
weakMap.set(obj, 'hello');


// looping through WeakMap
for (let i of weakMap) {

    console.log(i);  // TypeError
}
 
PREVIOUS NEXT
Tagged: #javascript #WeakMaps #Are #Not #iterable
ADD COMMENT
Topic
Name
2+6 =