News for hackers. Stuff that matters.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi... by z3t4 on Wednesday May 24, 2017 @06:57AM (#14409034)
embrace higher-order functions. Use named functions and closures!

example code:

  var anchors = document.getElementsByTagName(“a”);
  for(var i=0,len=anchors.length; i<len; i++){
    alertClickAnchor(i); // Named function
  }

  function alertClickAnchor(i) { // Closure
    anchors[i].onclick = function() {
      alert(i);
    }
  }
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi... by sametmax on Wednesday May 24, 2017 @08:59AM (#14409657)
This makes anything but basic life cycles very hard to read.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi... by z3t4 on Wednesday May 24, 2017 @10:13AM (#14410125)
You can look at each function at a time and only have to understand what that function does. No more nesting.