Sunday 23 December 2018

javascript - How do I get the key of object inside object?

I have an object and a for in loop that looks like this:



var golom = {
MRTU03: {
Temp: "10",
Sp: "11"
},

MRTU09: {
Temp: "8",
Sp: "7"
}
};
for (var f in golom) {
$('body').append('hi ' + golom[f]);
}



As it is it's printing:



hi [object Object]hi [object Object]



to the body, but how can I get it to print



hi MRTU03hi MRTU09



??




Thanks!

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...