JavaScript Error – How to Fix ‘Cannot Read Property ‘Push’ of Undefined’ arraydata-pushjavascript When pushing an array's contents i get here is my code Best Answer This is because the context of this has changed within your each. Try this: const self = this; $.each(res, function(index, value) { self.qtyOptions.push(value); } Related SolutionsJavaScript – Uncaught TypeError: Cannot Read Property ‘HoverAlls’ of Null I'm guessing above code is jQuery. In that case you'll need to wrap the code to prevent issues with the Magento Prototype library <default> <reference name="head"> <block type="core/text" name="your.block.name"> <action method="setText"> <text><![CDATA[<script type="text/javascript"> jQuery.noConflict(); // prevent conflicts with prototype (function($){ // and wrap it $(window).load(function(){ $('.HoverAlls_Caption').HoverAlls({ "coords":"0,100||0,75||0,100", "text_coords":"0,50||0,5||0,50", "speed" : "220,220", "text_speed" : "400,200", "opacity" : "0,1", "link_control" : "false,_blank", "bg_class" : "captionBackground", "text_class" : "captionText" }); }); })(jQuery); </script>]]></text> </action> </block> </reference> </default> Magento 1.9 – Fix Uncaught TypeError: Cannot Read Property Magento use prototype.js framework. So if you want to use jQuery to read an element. Use jQuery instead of $ jQuery('a').removeAttr('href'); Related TopicMagento – Magento 2 : Cannot Read Property “quoteData” of undefinedMagento – Uncaught TypeError: Cannot read property ‘innerHTML’ of null
Best Answer
This is because the context of
this
has changed within your each. Try this: