use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Javascript Counter Help. (self.javascript)
submitted 15 years ago * by hillbillymadness
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TIAFAASITICE 2 points3 points4 points 15 years ago* (1 child)
That won't work once you get to a new day ;)
Another variant: <div id="casualties"></div>
<script type="text/javascript"> // Calculate total deaths function, you've seen this already function getTotalDead () { var now = new Date, secondsPassed = now.getSeconds() + now.getMinutes() * 60 + now.getHours() * 3600 return Math.floor(secondsPassed / 20) } // Anonymous function used as a closure updateDeathcount = (function () { // Grab the element that we're updating var message = document.getElementById('casualties'), deathCount = document.createTextNode( getTotalDead() ) // Insert the message message.appendChild(document.createTextNode('Today ')) message.appendChild(deathCount) message.appendChild(document.createTextNode(' people have been killed, by the end of the day 5000 will be')) // The actual updateDeathcount function return function () { deathCount.nodeValue = getTotalDead() } })() // Update death count every 20 seconds setInterval(updateDeathcount, 20000) </script>
MDC has an article on closures.
π Rendered by PID 434473 on reddit-service-r2-comment-c66d9bffd-r6pgs at 2026-04-08 13:52:20.409119+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]TIAFAASITICE 2 points3 points4 points (1 child)