これが私たちが持っているものです:
var MyObject = function(){
var contents = [undefined,2,undefined,4,5];
this.getContents = function(){
return contents;
}
}
var o = new MyObject();
ご理解のとおりo.getContents()
、[undefined,2,undefined,4,5]
私がやりたいのは、配列全体を上書きせずに、プライベートをcontents
パブリックにせず、オブジェクト コード全般を変更せずに、そのプライベート配列の未定義の値を削除することです。