I am trying to upgrade my code to ES6 as I am using Node 4.0 and really love its features so far. However, I am having problems with the new ES6 Map data structure, as it behaves differently with {} when using Array as the key. I use it as a counter card.
I am running this code and I would like to know how I can use arrays as keys for Map .
"use strict"; var a = new Map(); a.set(['x','y'], 1); console.log(a.get(['x','y'])); var b = {}; b[['x','y']] = 1; console.log(b[['x','y']]);
Prints the following, and the first line should be 1 , not undefined :
undefined 1
The original JS card builds the key, and I don't want to do the same type of stringify hack with the new ES6 Map .
What can I do to use arrays as keys reliably for ES6 Map ?
source share