Hacker News new | past | comments | ask | show | jobs | submit login
A Classic JavaScript Interview Question (medium.com/chcokr)
5 points by chcokr on Jan 24, 2015 | hide | past | favorite | 1 comment



I like your IIFE there. It's more elegant than the way I usually see this one fixed:

  for (var i = 0; i < domElems.length; ++i) {
    domElems[i].onclick = clickHandler(i);
  }

  function clickHandler(n){
    return function(){
      console.log(n);
    };
  }




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: