AE Scripting: Array methods (forEach, IndexOf) not working in 2024?
Scripts that are working in 2023 are not working for me in 2024. It appears to be some javascript array methods that are causing the issue. I wrote a simple script to test and am getting the same results: works fine in 2023, does not work in 2024 or the latest beta. This is on an M2 Macbook Pro. Not sure if this is related to AE itself or something to do with my setup.
// testing script
function testForEachMethod() {
var testArray = [1, 2, 3, 4, 5];
var result = [];
// Using forEach to iterate over the array
testArray.forEach(function(element, index) {
result.push("Element " + index + ": " + element);
});
// Display the result
alert("forEach results:\n" + result.join("\n"));
}
function testIndexOf() {
var testArray = [1, 2, 3, 4, 5];
for (var i = 1; i <= 6; i++) {
// Loop through numbers 1-6 and use indexOf to determine if that number is in the array
if (testArray.indexOf(i) === -1) {
alert("Value " + i + " is not in the array.");
} else {
alert("Value " + i + " is in the array.");
}
}
}
testForEachMethod();
testIndexOf();
