I'm trying to use Immutable in a project with reactjs and flux.
Let's say I have a .js file with the code
console.log ( Immutable.Map({1: 2}).toString() )
I browserify this script and run it from the browser (Google Chrome), the result is:
"Map { "1": 2 }"
notice that the key, 1, is now a string, not a number.
If I try the same code directly in the console of the site http://facebook.github.io/immutable-js/ I get the correct result:
"Map { 1: 2 }"
Why is this happening and what can I do to get the correct result (key as number) in my script?
I'm using node v0.10.26, Browserify 5.12.0 and immutable 3.7.1
Giving Map an array of key value pairs seems to do the trick:
> Immutable.Map([[1, 2]]).toString()
'Map { 1: 2 }'
see https://facebook.github.io/immutable-js/docs/#/Map/Map for more info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With