For future stumblers upon; the answers given before only address a typo in the OP's question. As for speakMessage inheriting from baseFunction the OP's code is completely wrong and should/could look something like this:
(note that constructor functions should start with a capital letter)
function BaseFunction(args){
//name is instance specific
//defaults to World
this.name = (args&&args.name)?args.name:"World";
};
//shared members
BaseFunction.prototype.saySomething=function(){
return "From BaseFunction:"+this.name;
};
function SpeakMessage(args){
//re use BaseFunction constructor code
BaseFunction.call(this,args);
}
//inherit shared members from prototype
SpeakMessage.prototype = Object.create(BaseFunction.prototype);
//repair built in constructor value (or it'll point to BaseFunction)
SpeakMessage.prototype.constructor=SpeakMessage;
//extend saySomething, this is optional an shows how
// to add extra functionality to existing Parent functions
SpeakMessage.prototype.saySomething=function(){
return BaseFunction.prototype.saySomething.call(this) +
", from SpeakMessage:"+this.name;
};
var world = new SpeakMessage();//defaults name to be "world"
//following will output: From BaseFunction:World, from SpeakMessage:World
console.log(world.saySomething());
var op = new SpeakMessage({name:"OP"});
//following will output:From BaseFunction:OP, from SpeakMessage:OP
console.log(op.saySomething());
var parent = new BaseFunction();
console.log(parent.saySomething());//=From BaseFunction:World
As in comments; for more info about constructor functions and prototype: https://stackoverflow.com/a/16063711/1641941
As for the comment mentioning closures; you can use closures instead of constructor functions for simpler objects:
var baseFunction=function(message){
return function(){
console.log("Hello "+message);
};
}
var world = baseFunction("World");
var op = baseFunction("OP");
world();//=Hello World
op();//=Hello OP
More on closures here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Closures