Deleting Keys

Keys can be deleted from maps using the Map.delete and Map.deleteIn methods.

  1. let movie = Immutable.fromJS({
  2. name: 'Star Wars',
  3. episode: 7,
  4. actors: [
  5. { name: 'Daisy Ridley', character: 'Rey'},
  6. { name: 'Harrison Ford', character: 'Han Solo' }
  7. ],
  8. mpaa: {
  9. rating: 'PG-13',
  10. reason: 'sci-fi action violence'
  11. }
  12. });
  13. movie = movie.delete('mpaa');
  14. console.log(movie.toObject());
  15. /* writes
  16. { name: 'Star Wars',
  17. episode: 7,
  18. actors: List [ Map { "name": "Daisy Ridley", "character": "Rey" }, Map { "name": "Harrison Ford", "character": "Han Solo" } ] }
  19. */

原文: https://angular-2-training-book.rangle.io/handout/immutable/immutable-js/nested-objects/deleting_keys.html