javascript - Dynamically generate n js instance objects
漂亮男人
漂亮男人 2017-06-10 09:48:24
0
1
686


I want to control the number of elevators through buttons. What I first thought was to create an instance object through a for loop when the button is clicked, but the object variable name is changed after the for loop. becomes undefined, how should I create an instance object and call it in other codes

It should be that n elevators are connected in parallel. Later, I need to control which elevator to pick up people, so what I want is to generate 4 elevators through a for loop. Each elevator has a variable name, and then use the variable name to call the prototype method of the elevator.

漂亮男人
漂亮男人

reply all(1)
学习ing
let obj = {};
for (let i = 0; i < 4; i++) {
    obj[i] = {};
}
console.log(obj);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template