I have an object that looks like this:
var myObj = {
name:"Bacon",
fat:20,
carb:40
}
Is there a way to do a loop on the keys of the object, to then get its value?
You can traverse through javascript following way:
for (var key in p) {
if (p.hasOwnProperty(key)) {
alert(key + " -> " + p[key]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With