Last active
August 29, 2015 14:21
-
-
Save ianldgs/6d0bfdd7f7a48b075737 to your computer and use it in GitHub Desktop.
Simulating traits on javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
var trait = {} | |
trait.whatever = function (context) { | |
context.prototype.exec = function () { | |
console.log(this.i) | |
} | |
} | |
var A = function () { | |
this.i = 'teste _ A' | |
} | |
trait.whatever(A) | |
var B = function () { | |
this.i = 'teste _ B' | |
} | |
trait.whatever(B) | |
var a = new A(); | |
var b = new B(); | |
a.exec(); | |
b.exec(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment