Skip to content
Advertisement

Tag: immutability

React setState does not update a state array value

I am trying to change the state in a class component by using setState. More specific I have a table, and I want to edit/update one of its elements. For this case, I am passing the indeces to the handleTableFieldOnChange function for the position of the value in the array. Since I know that I should not mutate the state,

Enums in Javascript with ES6

I’m rebuilding an old Java project in Javascript, and realized that there’s no good way to do enums in JS. The best I can come up with is: The const keeps Colors from being reassigned, and freezing it prevents mutating the keys and values. I’m using Symbols so that Colors.RED is not equal to 0, or anything else besides itself.

Can anyone explain me what is state and mutable data?

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. http://en.wikipedia.org/wiki/Functional_programming Can anyone explain me what is state and mutable data? Can anyone give me examples in either JAVA or JavaScript. Answer mutable suggest anything that can change, i.e. an int In java a string is

Advertisement