动态将元素推入数组[Javascript]

时间:2013-04-23 07:38:58

标签: javascript html web maps

var stops = [
  {
    "Geometry": {
      "Latitude":52.1615470947258,
      "Longitude":20.80514430999756
    }
  },
  //next element of the same sort
]

我想使用javascript将元素推送到此数组中。我该怎么做?

2 个答案:

答案 0 :(得分:1)

您应该使用.push

stops.push(elements);

答案 1 :(得分:0)

这个对你的情况没有帮助吗?

var stops = [{"Geometry":"Latitude":52.1615470947258,"Longitude":20.80514430999756}},next element of the same sort}]

var newStops = {"Geometry2":{"Latitude":52.1615470947258,"Longitude":20.80514430999756}}

stops.push(newStops)