class Shape { desc = ""; constructor( _desc ) { this.desc = _desc; } get2Desc() { return this.desc + this.desc; } }Instance of class and calling class method:
b.addEventListener( 'click', function () { const myShape = new Shape( "this is a desc" ); console.log( myShape.get2Desc() ); }Output:
this is a descthis is a desc
No comments:
Post a Comment