In PHP, we can loop through an associative array, and get the values of both the key and the value like this:
$myArray = array(
    'key1' => 'value1',
    'key2' => 'value2'
);
foreach($myArray as $key => $val){
    echo 'The value of "'.$key.'" is "'.$val.'".\n';
}
/* Output:
The value of "key1" is "value1".
The value of "key2" is "value2".
*/
Is there any way this can be done in javascript?
myObject = { 
    'key1': 'value1',
    'key2': 'value2'
};
for (val in myObject) {
    // check hasOwnProperty and what not...
    // Now, how do I get the key value?
}
 
     
    