Hacker News new | ask | show | jobs
by dmak 4320 days ago
Why do you think its terrible?
1 comments

the + operator, is it concatting strings, or adding? who knows.

the scoping sucks, e.g.

  (function() {
    var x = 1;
    console.log( x );
    if ( x ) {
      var y = 2;
    }
  
    console.log( y );
  })()
why is y defined? its being called out of the block it was declared in?

there's no proper foreach using other files is an effort and requires hacks to get them loaded. callbacks everywhere. variable names as object keys is a pain regex is a pita

i just don't like it, i have no idea why it's become so popular recently, i can understand it runs in the browser and everyone has a browser, but why server side stuff?

but whatever, each to their own i guess

> why is y defined? its being called out of the block it was declared in?

Javascript doesn't have block scope; above example is equivalent to:

  (function() {
    var x, y;
    x = 1;
    console.log( x );
    if ( x ) {
      y = 2;
    }
  
    console.log( y );
  })()
Variable declarations are always hoisted to the top of containing scope.