Advertisement
YellowAfterlife

Haxe-alike approach to JavaScript classes

Mar 31st, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function $extend(from, fields) {
  2.     function inherit() {}; inherit.prototype = from; var proto = new inherit();
  3.     for (var name in fields) proto[name] = fields[name];
  4.     return proto;
  5. }
  6. var Class = function() {
  7.     /* constructor */
  8. };
  9. Class.prototype = $extend(ParentClass, {
  10.     methodName: function(methodArg) {
  11.         /* method contents */
  12.     }
  13. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement