Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
JavaScript
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Functions as roles (Traits and Mixins) ==== {{Main|Role-oriented programming|Traits (computer science)|Mixin}} JavaScript natively supports various function-based implementations of [[Role-oriented programming|Role]]<ref>[https://peterseliger.blogspot.de/2014/04/the-many-talents-of-javascript.html#the-many-talents-of-javascript-for-generalizing-role-oriented-programming-approaches-like-traits-and-mixins The many talents of JavaScript for generalizing Role-Oriented Programming approaches like Traits and Mixins] {{Webarchive|url=https://web.archive.org/web/20171005050713/https://peterseliger.blogspot.de/2014/04/the-many-talents-of-javascript.html#the-many-talents-of-javascript-for-generalizing-role-oriented-programming-approaches-like-traits-and-mixins |date=2017-10-05 }}, Peterseliger.blogspot.de, April 11, 2014.</ref> patterns like [[Traits (computer science)|Traits]]<ref>[https://soft.vub.ac.be/~tvcutsem/traitsjs/ Traits for JavaScript] {{Webarchive|url=https://web.archive.org/web/20140724052500/https://soft.vub.ac.be/~tvcutsem/traitsjs/ |date=2014-07-24 }}, 2010.</ref><ref>{{cite web |url=https://cocktailjs.github.io/ |title=Home | CocktailJS |website=Cocktailjs.github.io |access-date=February 24, 2017 |archive-date=February 4, 2017 |archive-url=https://web.archive.org/web/20170204083608/https://cocktailjs.github.io/ |url-status=live }}</ref> and [[Mixin]]s.<ref>{{cite web |url-status=live |first1=Angus |last1=Croll |url=https://javascriptweblog.wordpress.com/2011/05/31/a-fresh-look-at-javascript-mixins/ |title=A fresh look at JavaScript Mixins |archive-url=https://web.archive.org/web/20200415004603/https://javascriptweblog.wordpress.com/2011/05/31/a-fresh-look-at-javascript-mixins/ |archive-date=2020-04-15 |date=May 31, 2011 |website= JavaScript, JavaScript… }}</ref> Such a function defines additional behavior by at least one method bound to the <code>this</code> keyword within its <code>function</code> body. A Role then has to be delegated explicitly via <code>call</code> or <code>apply</code> to objects that need to feature additional behavior that is not shared via the prototype chain.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)