Copy link to clipboard
Copied
When I call the following in AE's Script Editor:
var arr = [ "a", "b", "c" ];
for(var i=0; i < arr.length; i++) {
arr[i];
}Only the third (last) object is printed in the consol. Is this normal? I mean the whole script runs but only the last object is printed? I would really appreciate if somebody could explain me why don't
a
b
c
is printed.
Is it something that can be adjusted somewhere in the settings?
Actually, in your code you are printing nothing to console. You are just looping through an array. The following method prints on every iteration.
var arr = [ "a", "b", "c" ];
for(var i=0; i < arr.length; i++) {
$.write( arr );
}
Copy link to clipboard
Copied
Actually, in your code you are printing nothing to console. You are just looping through an array. The following method prints on every iteration.
var arr = [ "a", "b", "c" ];
for(var i=0; i < arr.length; i++) {
$.write( arr );
}
Copy link to clipboard
Copied
Tomas is right. When you execute a script, its result is simply the value of the last statement that is evaluated. If you want to log intermediate results, you can use $.write.
Copy link to clipboard
Copied
Thanks for the explanation! It was misleading that my console printed something, so I believed it's a printed log, but it's clear now.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more