Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



No, 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.


Functions define scope. The end. Not hard. One rule.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: