Be Careful with Array Mutators

Photo by Corinne Kutz on Unsplash

A while ago, I wrote a linting rule to highlight an error that I’d made on a few occasions. Let’s look at the error — and its variations — and then at the rule that prevents it.

The error

If you are used to working with fluent APIs — perhaps with D3 or lodash — it feels natural to write Array-based code like this:

const developers = employees…

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Counting Frequency

Going Express with Node.js [Part #2]

Guide to Vue.js for jQuery developers

JavaScript Array Methods — Iteration

JavaScript — Iteration Methods

What’s up with ES2020?

Journal: Do you need to care about re-renders in react?

Managing Access Tokens in React or React Native with Axios and Context API.

Mocking Dates in JavaScript Unit Tests

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nicholas Jamieson

Nicholas Jamieson

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

More from Medium

JavaScript — Prerequisites for Functional Programming: Higher-Order Functions

4 Ways to Handle Async Operations in Javascript

4 Ways to Handle Async Operations in Javascript

SOLID design principles with JAVASCRIPT

Generate TypeScript Declaration Files for JavaScript Files

The JavaScript logo with an arrow pointing towards the TypeScript logo