Created
October 22, 2015 15:28
-
-
Save gobwas/d102be7532925cfa5c98 to your computer and use it in GitHub Desktop.
Callable object
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
function Actor(min, max) { | |
var self = this; | |
this.id = Math.floor(min + Math.random() * (max - min + 1)); | |
var actor = function() { return self.action.apply(actor, arguments); } | |
Object.setPrototypeOf(actor, this); | |
return actor; | |
} | |
Actor.prototype.action = function() { | |
console.log('action', this.id); | |
} | |
Object.setPrototypeOf(Actor.prototype, Function.prototype) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment