简体   繁体   中英

Javascript - Array of objects, objects contain another array and an int

I have no idea how to approach this, and I was hoping someone had a little input. I can't find any information on how to load an array that is inside an Object. Below is the function I'm concerned with.

function Frame(time){
    this.minutes = new Array();
    this.time = time;
}

Now if I make an array of Frames, how would I access the minutes array in each Frame?

In JavaScript, you can also create an array as:

function Frame(time){ 
    this.minutes = []; 
    this.time = time; 
} 

And if you had an array of frames, you would have to loop through and access each frame, grabbing the minutes.

for (int i = 0, len = frames.length; i < len; i++)
{
    var min = frames[i].minutes;
    var first = min[0]; // or whatever else is needed
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM