class f{ play(){ this.z=this.x[1]; this.z=this.z+this.x[2]; return this.z; } } function sample(){ var x=new Array(); x[1]=4; x[2]=5; sub =new f(); sub.x=x; a=sub.play(); alert(a); }