Object.defineProperty in constructor, getter and setter method
<p>The exact same question is asked here <a href="https://stackoverflow.com/questions/28987543/can-someone-explain-how-object-defineproperty-work-in-constructor-function-in-ja">define property in constructor</a>, but i don't feel that the answers are satisfactory.
The code is copied from the book "The Principles of Object Oriented JavaScript", with a slight modification to make the question more clear.</p>

<pre><code>function Person(xname) {
    Object.defineProperty(this, "name", {
        get: function() {
            return xname;
        },
        set: function(newName) {
            name = newName;
        },
        configurable: true,
        enumerable: true
    });
    this.sayName = function() {
        console.log(this.name);
    };
}

var One = new Person("Mark");

One.sayName();
console.log(One.name);
//output:
//Mark
//Mark
</code></pre>

<p>I have modified parameter <strong>name</strong> to <strong>xname</strong>, because it was even more confusing the use of local variable and object property with the same name.</p>

<p>I doubt that this code is working as intended but it confuses me even the way that it is doing something.</p>

<ol>
<li><p>I understand that it is using Object.defineProperty inside the constructor to create a property on the newly created instance called "name".</p></li>
<li><p>The getter method returns <strong>xname</strong> and yet <strong>xname</strong> goes out scope after the line: var One = new Person("Mark"); How can later in the code object's One getter manage to return the value of <strong>xname</strong>??</p></li>
<li><p>And it <strong><em>is</em></strong> the value of <strong>xname</strong>, because if i change the getter method to return <strong>name</strong>, like it should work, the engine reports an error <strong>name</strong> is not defined. (get: function() {return name;})</p></li>
<li><p>Not to mention that the setter method doesn't work at all. If i code One.name = "Mickey", One.name is still set to "Mark".</p></li>
</ol>

<p>There is no assignment of xname to .name or there is but I don't see it?!</p>