i have created a constructor function in javascript
function hello () {
name = 'shahin';
age= 22;
mesg = function () {
return 'My name is ' + this.name + 'and i am '+ this.age + 'old';
}
}
console.log(hello.mesg());
and instead creating of new constructor from it i just wanted to whether it is working as a normal function or not. hence try with the console and see that error : "TypeError: hello.mesg is not a function.
`
function hello () {
this.name = 'shahin';
this.age= 22;
this.mesg = function () {
return 'My name is ' + this.name + ' and i am '+ this.age + ' years old';
}
}
console.log(hello.mesg())
I even try with this and got the same error
newkeyword,thiswill be bound towindow.