JSFiddle - React, Tailwind, and code Playground
by David Buzatto
JavaScript
class A {
constructor( v, w ) {
this.v = v;
this.w = w;
}
toString() {
return "A: " + this.v + " " + this.w;
}
}
class B {
constructor( v, w ) {
this.v = v;
this.w = w;
}
toString() {
return "B: " + this.v + " " + this.w;
}
}
function somar( e ) {
e.v++;
e.w++;
}
function t() {
let a = new A( 1, 2 );
let b = new B( 3, 4 );
console.log( a.toString() );
console.log( b.toString() );
somar( a );
somar( b );
console.log( a.toString() );
console.log( b.toString() );
}
t();