Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Searching array key with reserved keyword

I have created array as below

["lists", { "getByTitle": "CardOperation" }, "items", { "filter": "Id eq 1" }, { "select": ["Title", "CustomerAge"] }];

Now one key as filter I want find it to know it is exists in array but as it is reserved keyword i cannot search it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tired

array.filter //not working

array["filter"] // not working

what should i do in this case, I am trying to find out if the array has an object with a key of filter at any index

>Solution :

This is probably what you want:

const hasObject = myArray.find(obj => typeof obj === 'object' && obj !== null && obj["filter"]) ? true : false;

This loops through the array and returns true if an object with key "filter" exists, or otherwise, returns false.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading