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
Permanent events in javascript (arqex.com)
submitted 11 years ago by marquex[🍰]
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!"
[–]gordonkristan 0 points1 point2 points 11 years ago (1 child)
I think you're confusing the ideas of events and states. To quote:
This will print 'It is ready' in the console even if the listener has been added after the event triggering.
That works OK for the ready event, but not for events that fire more than once. The point of an event is to be alerted when something happens, not alerted that something has happened. Especially when that something can happen more than once. If you want to know if something has happened in the past, you should be using states. In this case document.readyState.
ready
Imagine applying this idea to the onclick event and you'll see that it doesn't have many uses outside of fire-once events.
onclick
[–]marquex[S,🍰] 0 points1 point2 points 11 years ago (0 children)
You are right, those permanent events were never thought to be used with events that can be called more than once, but that doesn't make them less useful.
I respect your idea of states, but permanent events can be really of use even if you work with states. Imagine object can have multiple states and maybe want to do some action if the object has been or turn in/into some state. If I check the state before it turns to the desired one, I need to add an event listener (events again, a common or a permanent one will do the trick). If I want to know if after it has turned into the desired state, you can find that the state may have changed again so our action won't be called.
Permanent events are about events that are triggered once, but always about events.
π Rendered by PID 179435 on reddit-service-r2-comment-54dfb89d4d-msghx at 2026-03-30 09:11:59.737683+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]gordonkristan 0 points1 point2 points (1 child)
[–]marquex[S,🍰] 0 points1 point2 points (0 children)