How to check string key is available in a JavaScript object
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi All,
How to check system property stringKeys are available in Object Or Not ?
I have below Object & Property :
var myObject = {
"name": "ServiceNow",
"version": "Quebec",
"Year":"2025",
"Country":"Canada"
};
system property: StringKeys
name, year
// ---I tried below script which is working fine--//
var fields = gs.getProperty("StringKeys").split(',');
for(var key in fields) {
if(fields[key] in myObject) {
gs.info("Success ");
}
}
Can you help me is there better way to check string keys available in Object Or not ?
10 REPLIES 10
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hey @chanikya ,
I hope you saw my reply.
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.
Thanks,
Bhimashankar H