标签:
Immutable.js provides several methods to iterate over an Immutable.Map(). These also apply to the other immutable structures found within the Immutable.js family, such as Set and List. The primary methods are map and forEach, but we will also cover filter and groupBy.
// map() return todos.map(todo => { return todo.text }); // filter() return todos.filter(todo => { return todo.completed; }) // groupBy() --> return new Immtuable Map return todos.groupBy(todo => { return todo.completed })
Notice, only forEach method will actually change its value!
// forEach() function markAllTodosAsComplete(todos) { return todos.forEach(todo => { todo.completed = true }); }
[Immutable,js] Iterating Over an Immutable.js Map()
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5229556.html