I was wondering if there's a way to do something like a PHP foreach
loop in JavaScript. The functionality I'm looking for is something like this PHP Snippet:
foreach($data as $key => $value) { }
I was looking at the JS for..in
loop, but there seems to be no way to specify the as
. If I do this with a 'normal' for loop (for(var i = 0; i < data.length; i++
), is there a way to grab the key => value pairs?