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

jQuery is hardly a good benchmark for current js style. You'll find completely different shapes in other libraries.


JS is the new C++. It's several different languages depending on which subset you use: jQuery style, pyramid callbacks, promises, async/await, etc.


always name your anonymous functions. that way it will be easier to break them out of the pyramid, make them testable, and easier to debug.


... and it will also make them not anonymous functions :)


A named "anonymous" function (lets call it lamda function to make it less confusing) is still a lamda function, but with a name ... It can not be called from elsewhere. So you get all the benefits from lamda functions! There's no advantage to not naming variables.

  var fs = require("fs");
  fs.readFile("somefile.txt", function readSomeFile(err, text) {
    if(err) throw err;
    else console.log(data);
  }




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

Search: