Is there a different method to iterate through my array of objects? The engine version on the application I'm using seems to be outdated and doesn't support myArray.forEach((obj) => {
, but it works when dealing with single object arrays. Try using Object.keys(myArray).forEach()
.
{"jurisdiction":"SCPB - LON"},{"firstName":"David Dynamic"}
var array = []
$('input:checked').each(function() {
var key_ = $(this).attr('name')
var val = $(this).attr('name').val();
var obj = {
[key_]: val
};
array.push(obj);
array.forEach((obj) => {
Object.keys(obj).forEach((key) => {
alert(key: " + key + " - value: " + obj[key]);
});
});
});
The error message from the webapp:
JST-310000 Error while compiling script '_webApp_APP303__preview' line 175: syntax error (line=' array.forEach((obj) => { ' token='> { '). SCR-160032 JavaScript: error while compiling script '_webApp_APP303__preview'.
I also attempted another loop method without success.
array.forEach(obj => {
for (let key in obj) {
logInfo(`${key}: ${obj[key]}`);
}
});
JST-310000 Error while compiling script '_webApp_APP303__preview' line 176: syntax error (line='array.forEach(obj => { ' token='> { '). SCR-160032 JavaScript: error while compiling script '_webApp_APP303__preview'.