Getter/setter on javascript array?

前端 未结 10 2172
闹比i
闹比i 2020-12-01 02:12

Is there a way to get a get/set behaviour on an array? I imagine something like this:

var arr = [\'one\', \'two\', \'three\'];
var _arr = new Array();

for (         


        
10条回答
  •  离开以前
    2020-12-01 02:31

    Why not create a new class for the inner objects?

    var a = new Car();
    
    function Car()
    {
       // here create the setters or getters necessary
    }
    

    And then,

    arr = new Array[a, new Car()]
    

    I think you get the idea.

提交回复
热议问题