Normal object in JavaScript
var person = {
name: 'Byomkesh Bakshi',
occupation: 'being awesome'
};
person.occupation = 'being not so awesome';
console.log(person);
// Object {name: "Byomkesh Bakshi", occupation: "being not so awesome"}
With immutable-js (a library from facebook)
var map1 = Immutable.Map({a:1, b:2, c:3});
var map2 = map1.set('b', 50);
map1.get('b'); // 2
map2.get('b'); // 50
History.prototype.undo = function() {
if(currentIndex === 0) {
return this.history[currentIndex];
}
currentIndex -= 1;
return this.getCurrentItem();
}
History.prototype.redo = function() {
if(currentIndex === (this.history.length - 1)) {
return this.history[currentIndex];
}
currentIndex += 1;
return this.getCurrentItem();
}