Hi Frederick,
re:
> Is this because the file list does not support the form as used for the
> directory list - for (var d in dirlist)?
Yes, here the dirlist variable is a native JavaScript Array that was created by the JavaScript runtime.
The files variable is a MoiList object created by Moi,
Until recently in v5 objects that were created by Moi did not support the for ( propname in object ) syntax.
Since v5 Mar-29-2023, the for ( propname in object ) syntax is now supported on objects created by MoI but it doesn't have the special behavior for JavaScript arrays.
It's generally considered a best practice to use a regular for () loop with an index variable to loop through the contents of an array and not for ... in .
Some info here:
https://stackoverflow.com/questions/5263847/javascript-loops-for-in-vs-for
https://www.geeksforgeeks.org/javascript/why-using-for-in-for-array-iteration-a-bad-idea-in-javascript/
- Michael
|