The CreatorCon Call for Content is officially open! Get started here.

How to check string key is available in a JavaScript object

chanikya
Kilo Sage

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

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