“JSON Search JavaScript” Kode Jawaban

JS Search Json

var data=[{name:"Afghanistan",code:"AF"},{name:"Åland Islands",code:"AX"},{name:"Albania",code:"AL"},{name:"Algeria",code:"DZ"}];

let country = data.find(el => el.code === "AL");
// => {name: "Albania", code: "AL"}
console.log(country["name"]);
Code Cat

JSON Search JavaScript

var results = [];
var searchField = "name";
var searchVal = "my Name";
for (var i=0 ; i < obj.list.length ; i++)
{
    if (obj.list[i][searchField] == searchVal) {
        results.push(obj.list[i]);
    }
}
Condemned Cockroach

Jawaban yang mirip dengan “JSON Search JavaScript”

Pertanyaan yang mirip dengan “JSON Search JavaScript”

Lebih banyak jawaban terkait untuk “JSON Search JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya