I have this array:
var shareholders = [“name1”, “name2”, “name3”];
This is function from HPSM that is fetching data from that array:
function getShareholders(RECORD)
{
var fShareholder = new SCFile("device");
var rc = fShareholder.doSelect("logical.name=\"" + RECORD + "\"");
if (rc == RC_SUCCESS)
{
print(fShareholder.shareholder_contacts);
return fShareholder.sharholder_contacts;
}
return null;
}
It returns them in array form but I need it to fetch one by one:
var users = new Array();
users[0] = “name1”
users[1] = “name2”
….
I have tried them to loop through for loop but without success.
You can use
forEach
function, which accepts acallback
function.forEach
method executes a provided function once for each array element.Syntax: