Mitul Dabhi
answered Nov 30 '-1 00:00
yes JavaScript Support forEach , see the following code
var jsondata=['product 1','product 2','Product 3 '];
jsondata.forEach(function (value,key) {
alert(value);
});
you can use forEach as you do in php but difference is you need to pass reference variable and second argument is key which array key to function argument forEach
so
foreach($array as $key=>$value) { //code here } become array.forEach(funcion(value,key){ //code here });