Skip to content

Commit 0ebe390

Browse files
Super (parent) methods in JS.
With a little extra effort, they are possible to achieve, but the situations where you'd want to use them are few and far between. Perhaps there's a different way for you to look at solving the problem, that doesn't involve using super methods?
1 parent bc25808 commit 0ebe390

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

super_methods.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function hoozit(id) {
2+
var secret = {};
3+
var that = gizmo(id, secret);
4+
var super_toString = that.toString;
5+
6+
that.test = function (testid) {
7+
return testid === secret.id;
8+
};
9+
10+
that.toString = function () {
11+
return super_toString.apply(that);
12+
};
13+
14+
return that;
15+
}

0 commit comments

Comments
 (0)