A property that is read-only outside of the class, but read-write for class members : <p>I'd like to have a property in my class that is readable, but not directly modifiable by code external to the class. Basically, equivalent of returning a const reference to member from a method in C++.</p>

<p>Writing something along those lines:</p>

<pre><code>class test {
    private readonly x_ = new Uint8Array([0, 1, 2]);
    public x() { return this.x_;}
}
</code></pre>

<p>does not work, because code like the following still compiles:</p>

<pre><code>let a = new test();
a.x()[0] = 1;
</code></pre>

<p>What's the correct way of achieving this?</p>
