我想知道是否有一种方法可以在JavaScript中实现PHPforeach
循环.我正在寻找的功能类似于以下PHP代码片段:
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?