Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MyConstructor() {
- var instance = function() {
- alert('yey');
- }
- instance.constructor = MyConstructor;
- instance.__proto__ = MyConstructor.prototype;
- return instance;
- }
- MyConstructor.prototype.instanceMethod = function() {
- alert('woo');
- }
- var myInstance = new MyConstructor;
- alert(myInstance instanceof MyConstructor); // true
- myInstance.instanceMethod(); // woo
- myInstance(); // yey
Add Comment
Please, Sign In to add comment