Answers for "loop json"

1

loop through json object javascript

var p = {
    0: "value1",
    "b": "value2",
    key: "value3"
};

for (var key of Object.keys(p)) {
    console.log(key + " -> " + p[key])
}
Posted by: Guest on August-10-2020
1

loop json

const p = {
    "p1": "value1",
    "p2": "value2",
    "p3": "value3"
};

for (let [key, value] of Object.entries(p)) {
  console.log(`${key}: ${value}`);
}
Posted by: Guest on September-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language