ConorReidd ConorReidd - 1 year ago 58
Javascript Question

Trying to push an array from an .each() into another array

I'm trying to push an associative array into an empty object and it's giving me the error:

Cannot read property '#<Object>' of undefined

The code I'm trying is

var arr = {};
$(".proj").each(function() {
arr.push[{name: "name"}];

I think it's something to do with the scope of
but i'm unsure, any help is appreciated

Answer Source

Check this code snippet

  var arr = [];
$(".proj").each(function() {
 arr.push({name: "name"})
<script src=""></script>
<div class="proj">

Hope this helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download