how do i check if the json object array contains the value defined or not?

You can combine basic array/object functions to archive your goal. But as i commented on your question, you should define strict filter criterias.

const data = {
    "ip": "",
    "version": "IPv4",
    "city": "Jakarta",
    "region": "Jakarta",
    "region_code": "JK",
    "country": "ID",
    "country_name": "Indonesia",
    "country_code": "ID",
    "country_code_iso3": "IDN",
    "country_capital": "Jakarta",
    "country_tld": ".id",
    "continent_code": "AS",
    "in_eu": false,
    "postal": null,
    "latitude": -6.1741,
    "longitude": 106.8296,
    "timezone": "Asia/Jakarta",
    "utc_offset": "+0700",
    "country_calling_code": "+62",
    "currency": "IDR",
    "currency_name": "Rupiah",
    "languages": "id,en,nl,jv",
    "country_area": 1919440.0,
    "country_population": 267663435.0,
    "asn": "AS18103",
    "org": "Neuviz Net"

// create a regex of each filter value
const filters = [
    "fastnet", "indosatm2",
    "telekomunikasi", "indosat",
    "cyberindo", "biznet", "xl",
    "telematika", "hutchison",
    "smartfren", "mnc",
    "wireless indonesia",
    "antar nusa", "biznet",
    "ezecom", "win", "axis",
    "linknet-fastnet", "indonesia",
    "bali", "linknet", "indosat",
    "antar nusa", "indo", "firstmedia",
    "s.i", "cambodia", "neuviz"
].map((v) => {
    return new RegExp(`${v}`, "gi");

// get array of values from object
// filter array based on the test criteria
let matches = Object.values(data).filter((v) => {

    // conver every value to astring
    let value = String(v).toLowerCase();

    // test each filter on value
    return filters.some((filter) => {

        // test the regular expression on the value
        return filter.test(value);



if (matches.length > 0) {

    console.log("Filter matched!", matches);

} else {

    console.log("Filte *not* matched")


The code is well documented, if you dont understand a snippet/chunk, let me know. If it dosnt work like expected, let me know too!

Happy coding!

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top