From the docs I’ve been reading, the following ought to create an Array
from the keys of a Map
:
var m = new Map();
m.set("a", 1);
m.set("b", 2);
var arr1 = Array.from(m.keys());
var arr2 = Array.from(m.values());
console.log(arr1.length);
console.log(arr2.length);
I’d expect that to print 2
for both arrays, but in reality both arrays are empty and it prints 0
. What gives?
Edit: This issue seems to occur on a specific webpage when I execute the above code in the Javascript console. If I execute it on other pages it works as expected.
Edit 2: Upon further investigation, it appears that the page in question is including prototype.js v1.6.1 which is somehow causing Array.from
to break.