How to add an method to a class in Javascript ES6
<p>I need do add a method to a Javascript class using the new syntax. I tried this way:</p>

<pre><code>class X{

    constructor() {
        this.a = 'b'
    }

    x(){

    }
}

X.prototype.y = function (){
    console.log('y')
}

var x = new X()

x.y()

console.log(X) // print the  the class but not the new method.
</code></pre>

<p>It just prints:</p>

<pre><code>class X{

    constructor() {
        this.a = 'b'
    }

    x(){}
}
</code></pre>

<p>But I expected</p>

<pre><code>class X{

        constructor() {
            this.a = 'b'
        }

        x(){}

        y(){
            console.log('y');
        }
    }
</code></pre>

<p>How could I add a new method to a Javascript class?</p>