“JSON Loop di JS” Kode Jawaban

Loop melalui JSON Object JavaScript

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

for (var key of Object.keys(p)) {
    console.log(key + " -> " + p[key])
}
Inquisitive Ibex

Loop melalui JSON Object JavaScript

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

for (var key in p) {
    if (p.hasOwnProperty(key)) {
        console.log(key + " -> " + p[key]);
    }
}
Motionless Meerkat

JSON Loop di JS

var elements = document.querySelectorAll("a");
for (var i=0; i<elements.length; i++) {
   elements[i].style.color = "red";
}
‍
Breakable Bat

Jawaban yang mirip dengan “JSON Loop di JS”

Pertanyaan yang mirip dengan “JSON Loop di JS”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya