4 ms·
No, the Javascript model is "you name things with `var`, you mutate things with `=`". Python went for a more complicated scheme of having every variable in a f
by whateverer 15y ago
No, the Javascript model is "you name things with `var`, you mutate things with `=`".
Python went for a more complicated scheme of having every variable in a function be a new binding when first assigned, and then it's just mutation (i.e. 'local'), unless explicitly declared to be nonlocal, but it still makes sense with their... penchant for mutable state.
And Coffescript instead went over to PHP to have some of the glue it was eating.
- Someone 15y agoNo, the Javascript model is "you name things with `var`, you mutate things with `=`". If only it were that simple. It also has "you create thing with `var` and sometimes with `=`", plus it does not have block scope: if( true) { var x = 1; } // x == 1 here.
- ryanflorence 15y agoFunctions define scope. The end. Not hard. One rule.