From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Ensuring immutability: ESLint

Ensuring immutability: ESLint - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Ensuring immutability: ESLint

- [Instructor] So, I talked in the previous video about the importance of immutability in functional programming. Immutability allows us to avoid the many bugs that occur in computer programs as a side effect of state change. It also means that we don't have to worry about using private variables to avoid changes coming from unexpected places, since we simply can't make changes to any piece of data. That being said, if we want to ensure complete immutability in JavaScript, there's something we need to keep in mind. While using the const keyword prevents us from directly changing the value of a piece of data, for example if we say const x equals five, we can't simply say x equals six, since this will throw an error. However, using const in JavaScript is a little funny when working with arrays and objects. For example, if we define an array called numbers, like this, const numbers, one two three four five, we can never directly redefine numbers as a different array like this, numbers…

Contents