How to create object array in javascript?


I'm new to javascript and would like to know if it is possible to create array of objects in javascript, if so, how do I do this? I know that to create an object I need to do the following:

var Ponto = function (latitude, longitude) {
    this.latitude = latitude;
    this.longitude = longitude;

var ponto = new Ponto(80,50);

My intention now was to create an array of points to be able to work with them, is this possible? I appreciate everyone's collaboration!


Use array.push() to add an item to the end of the array.

var sample = new Array();
sample.push(new Object());

To do this "n" times using loop:

var n = 100;
var sample = new Array();
for (var i = 0; i < n; i++)
    sample.push(new Object());
Scroll to Top