I am not able to understand why this code is not working. I am trying to understand the prototype in Javascript. If I am declaring a new function inside a function then why am I not able to call that function?
<script>
function Person(first) {
this.firstName = first;
}
Person.prototype.name=function() {
this.addLastNameInner=function() {
return this.firstName+" Appended last name";
}
}
Person.prototype.name.addLastName=function() {
return this.firstName+" Appended last name";
}
var pr=new Person('john');
alert(pr.name.addLastNameInner());//Not working
alert(pr.name.addLastName());//working fine
</script>