class hello{ hat(){ this.v=this.a+this.b; } } function sample(){ a=8; b=5; sub=new hello(); sub.a=a; sub.b=b; sub.hat(); v=sub.v; alert(v); }