SO - change prototype

http://stackoverflow.com/questions/8397539/change-prototype-within-function

by dzejkej

JavaScript

var Server = function() {
    // ...
};

_add = function(fnName, fn){
    Server.prototype[fnName] = fn;
    console.log(typeof(Server.prototype[fnName]));
};

_add('log', function(data){
    console.log(data);
});

console.log(typeof(Server.prototype.log));
                                        
var server = new Server();
server.log("### test ###");