Hello guys i'm trying objects in javascript/node.js, actually i'm having a hard time on objects with functions inside them. This is my sample code whish the output should be:
Rohan says: Hello World
Here is my func.js
var myObject = function(name) {
console.log(this.name + ' says: ');
this.talk = function(msg) {
console.log(msg);
}
};
var phil = function (name) {
this.name = name;
};
phil.prototype = new myObject();
var man = new phil('Rohan');
man.talk('Hello World');
I hope you can help me solve this problem in my code. Thanks guys.