← Back to context

Comment by tombert

1 day ago

I mean this is getting into splitting-hairs territory, but I would argue that rebinding is a form of mutation; the variable i is changing as far as the programmer is concerned.

If I were to write

    var i = new Obj(2)

    // do stuff 1
    
    i = new Obj(3)

    // do stuff 2

Then yes, that’s technically rebinding and not directly mutating the value in memory, but from “do stuff 2’s” perspective the value has changed. It still acts more or less the same as if it had directly changed.