javascript - calling internal method for each object in an array -


i have "class" properties , methods. , have instances of class in array in other place in code. want iterate through of them , each call method. this:

arr.foreach(draw()); 

but of course looks global function draw() not there. how access object's methods in situation?

i new javascript, assume might stupid question, can't find answer reason.

foreach takes callback accepts 3 arguments, array element, index, , array. need first. wrap call draw() in anonymous function , invoke on element function call.

arr.foreach(function(elem) { elem.draw(); }); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -