Find if a value exists in subarray

I use vuejs at my project.
I have an array as bellow.
How can I check if a value exists at domain_id of the array?
For example the value ‘5’ or say the value ‘6’
I use includes() but it seems it does not work

 1:['domain_id':5,'domain_urls':{'url':'','id':2}], etc

Before we give up on includes() being useless, can you please show us what you were doing with includes() ?

Note: you might want to try using find() instead.

I use
if (!this.productTotal.includes(value.domain_id))

Yes, I think that you’re right. includes is not the right solution for you.

Here’s a jsfiddle where I’ve shown findIndex and find being used to find and show different sets of related information.

const data = [
        'domain_id': 4,
        'domain_urls': {
            'url': '',
            'id': 1
        'domain_id': 5,
        'domain_urls': {
            'url': '',
            'id': 2
const domainIdSearchValue = 5;
const domainIdIndex = data.findIndex(
    (item) => item.domain_id === domainIdSearchValue
document.querySelector("#result").innerHTML +=
    `domainId of ${domainIdSearchValue}` +
    ` found at index ${domainIdIndex}\n`;

const domainIdData = data.find(
    (item) => item.domain_id === domainIdSearchValue
document.querySelector("#result").innerHTML += JSON.stringify(domainIdData, null, 4);

Thank you, it seems working.
My next question is how can I change the values of the element that exists at the array.
I use this bellow but it seems it does not work,what do I do wrong?Do I use the elements of array right?

It seems I do it ok and I have problems at my v-data-table, I will see and I will say.

Well, domain_urls has two properties. One property is called url and the other property is called id.
Why are you using a property called r_url, because that doesn’t exist as a property on the domain_urls object at all.

I extended the array, I do not write here all my code.
So I can write

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.