Article View: adobe.scripting.indesign
Article #2222Re: [JS] :: [CSX] - PageItem Stacking Order
From: Harbs
Date: Tue, 06 Jan 2009 19:23
Date: Tue, 06 Jan 2009 19:23
22 lines
1581 bytes
1581 bytes
Peter Kahrel wrote:
> But as a matter of interest, what's the ".slice(0)" doing there at the end of the first line?
>
I'm not sure if it really makes a difference in this case (I've never
bothered to check), but here's an article written by Kris Coppieters
which explains the idea behind it...
http://www.niemannross.com/developer/wiki/index.php?title=Avoiding_slowness_with_object_arrays
FWIW, I use this function to get an array when I deal with a large
number of objects and I don't specifically need a dynamic collection
over an array. I don't need to worry about whether I'm starting out with
an array or a collection and the difference in performance is tremendous:
function AsArray(collection){
if(collection instanceof Array){return collection.slice(0)}
return collection.everyItem().getElements().slice(0);
}
--
Harbs
http://www.in-tools.com
Technical Details
Message-ID:
<75CDC3E916B8BB557287CC239270E8A1@in.webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b767cf.-1@webcrossing.la2eafNXanI> <59b767cf.11@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,5dfad1e4d169194d X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Harbs Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: [JS] :: [CSX] - PageItem Stacking Order Message-ID: <75CDC3E916B8BB557287CC239270E8A1@in.webcrossing.la2eafNXanI> Date: Tue, 6 Jan 2009 11:23:54 -0800 References: <59b767cf.-1@webcrossing.la2eafNXanI> <59b767cf.11@webcrossing.la2eafNXanI> Lines: 26 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit