Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

Mutator functions

A common source of unexpected problems comes from the fact that several JS methods actually modify the underlying object. In this case, by merely using them, you will be causing a side-effect, which you may even not recognize. Arrays are the basic source of problems and the list of troublesome methods is not short. (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Mutator_methods for more on each method.)

  • .copyWithin() lets you copy elements within the array
  • .fill() fills an array with a given value
  • .push() and .pop() let you add or delete elements at the end of an array
  • .shift() and .unshift() work the same way, but at the beginning of the array
  • .splice() lets you add or delete ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content