function myImages(){ var self = this; this.images = new Array(); this.add_img = function(count){ self.images.push(count); } } var o = new myImages(); o.add_img(1); alert(o.images); o.add_img(2); alert(o.images);