TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Classic JavaScript Interview Question

5 pointsby chcokrover 10 years ago

1 comment

eastbayjakeover 10 years ago
I like your IIFE there. It&#x27;s more elegant than the way I usually see this one fixed:<p><pre><code> for (var i = 0; i &lt; domElems.length; ++i) { domElems[i].onclick = clickHandler(i); } function clickHandler(n){ return function(){ console.log(n); }; }</code></pre>