ConorReidd ConorReidd - 11 months ago 37
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