TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JavaScript closures and recursion

14 点作者 ecounysis超过 14 年前

2 条评论

tlrobinson超过 14 年前
I'm sorry, what's so special about this bit of code?<p>It doesn't seem very interesting unless you weren't aware of JavaScript's functional nature, and it's actually more complicated than it needs to be, unless I'm missing something. Here's how I'd do it:<p><pre><code> function startSlideshow(ms) { var index = -1; var count = $(".change_link").length - 1; return setInterval(function() { index = (index + 1) % count; $('.slideshow').blinds_change(index); }, ms); }</code></pre>
评论 #1940984 未加载
评论 #1941654 未加载
ecounysis超过 14 年前
I suppose there's nothing too special abot the code. I have never seen a very good explanation of closures in javascript, so I thought I'd share it for anyone else who might benefit from it. You are more than welcome to not be impressed. In which case you are not likely the intended audience.
评论 #1941215 未加载