Node.js immutable Map
//Immutable data cannot be changed once created, //leading to much simpler application development, //no defensive copying, and enabling advanced memoization and //change detection techniques with simple logic. var Immutable = require('immutable'); var map1 = Immutable.Map({a:1, b:2, c:3}); var map2 = map1.set('b', 50); console.log("map1.b === " ,map1.get('b')); console.log("map2.b === " ,map2.get('b')); var Immutable = require('immutable'); var map1 = Immutable.Map({a:1, b:2, c:3, d:4}); var map2 = Immutable.Map({c:10, a:20, t:30}); var obj = {d:100, o:200, g:300}; var map3 = map1.merge(map2, obj); console.log(map3.toJS());//from w ww . j a v a2 s . c o m var Immutable = require('immutable'); var deep = Immutable.Map({ a: 1, b: 2, c: Immutable.List.of(3, 4, 5) }); console.log("to using .toObject method",deep.toObject()); // { a: 1, b: 2, c: List [ 3, 4, 5 ] } console.log("to using .toArray method",deep.toArray()); // [ 1, 2, List [ 3, 4, 5 ] ] console.log("to using .toJS method",deep.toJS()); // { a: 1, b: 2, c: [ 3, 4, 5 ] } console.log("to using JSON.stringfy method" ,JSON.stringify(deep)) // '{"a":1,"b":2,"c":[3,4,5]}'