Meaning of prototype in javascript
<p>I tried to understand the meaning of prototype in javascript</p>

<p>I wrote short code of inheritance of reader from Person</p>

<pre><code>&lt;script&gt;

/* Class Person. */
function Person(name) {
    this.name = name;
}

Person.prototype.getName = function() {
    return this.name;
}

var reader = new Person('John Smith');
alert(reader.getName());

&lt;/script&gt;
</code></pre>

<p>what is the diffrerent I was delete the line of  Person.prototype.getName = function() {
    return this.name;
    } and create it in the Person object for example</p>

<pre><code>&lt;script&gt;
/* Class Person. */
function Person(name) {
    this.name = name;
    this.getName = function() { return this.name;}
}


var reader = new Person('John Smith');
alert(reader.getName());

&lt;/script&gt;
</code></pre>

<p>I got the same result of getName()</p>
