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

I get "const", but is "let" really that big a deal? Are your functions so deeply nested that you need block scope inside of if statements and for loops? (vs forEach callbacks or IIFE blocks or simply splitting complicated stuff into smaller functions)

There is some cool stuff in ES6, but "let" is kind of a yawn, and "class" most definitely is NOT something I really needed.

But I'm still running ES5 on IE11 at work, so it's academic :-(



Sometimes you just need to do something the old way:

  let element = document.getElementById('some-element');
  while (element) {
    // do something
    element = element.parentElement;
  }
let doesn't get in the way with behavior such as hoisting, and the code will break if you redeclare a variable.


How does var/hoisting get in the way of that, or at least, that particular, construct?

FWIW, that would also be a nice "for" loop :-)

    var el
    for (
        el = document.getElement... ;
        el ;
        el = el.parentElement
    ) {
        // do something
    }




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

Search: