/    Sign up×
Community /Pin to ProfileBookmark

How to Change Function Scope?

I recently became aware of the Delegate class in ActionScript, which allows one to change the scope in which a function is executed. An example would be assigning an event handler from within a class method, and needing the event handler to be aware of class properties.

I was wondering if anyone knows of something equivalent in JavaScript? I had similar trouble with a JavaScript problem a while back, and if something like ActionScript’s Delegate class exists in JavaScript I’d love to know about it!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 08.2007 — Javascript has no classes. At least not the present on used versions. It works as a prototyped language, that means you have to build whichever "pseudo classes" you want...

At least for me, you question is too vague... can you detail a little bit? You want to create an event for an element and fire a function with it? You want to add/suspend a function when an event occurs? Or what?
×

Success!

Help @safetycopy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...