imagine building an app using javascript(react-native) that get list of skills which will be displayed to the user to select and the same list displayed as interest for the user to do the same if you try to treat them seperately but from the same source you get a shit result e.g

const list = responseFromApi;//array of object
let skills = list;;
let interest = list;

skills.checked = true;

interest is changed and the list constant variable is changed the values change were ever the list variable is assign to a variable and the variable is tempered.

the above code was the fustration i got with javascript when i didnt know of the mutation guy.

Mutation is a nightmare never knew javascript object are passed by reference which make them mutable this sucks....

another crazy behavior below though the same;

const person = {name:'Dan',age:43} //object
let person0 = person;
let person1 = person;
person1.name = 'David'
the value of both person0 and person get change.

this is madness .

  • 1
    I think you'd like Rust, or any immutable by default language. Maybe Elm is immutable by default?
  • 1
    tanks i think elm is immutable by default as stated in the documentation i will give it a try .
  • 0
    @solex have good time!
Add Comment