I have an item that is structured like this. It contains attributes that reference a function. What I am trying to achieve is to eliminate the repetition of 'DEVELOPER' (once for the attribute name and once for the parameter value) by dynamically fetching the current attribute being called.
Moreover, I prefer not to include 'DEVELOPER' as an argument in the initial invocation so that intellisense can detect it automatically.
return {
DEVELOPER: function ()
{
return getEmailRecipients("DEVELOPER")
}
}
//the invocation looks like this.
emailGroups.DEVELOPER();
Essentially, I aim to accomplish something similar to the following:
return {
DEVELOPER: function ()
{
return getEmailRecipients({this.currentPropName}) //This should result in the value of DEVELOPER.
}
}
If there is a more effective approach for achieving this task, I am open to suggestions.
Thank you in advance!