Thanks for the link Kasyan, and also thanks for asking the question in the first place, I learnt a lot from this thread.
I now have every line of Marcs code figured out.
If anyone is interested in seeing my lengthy annotations you can see them here.
Regarding the F.cache || (F.cache={});
line it's purpose is to create a private memory store as an object - prototype of the function F if and only if it does not exist in that targetengine. As such different results could be produced by re-running a script in a main indesign target engine than re-running it in a "session" target engine or a main ESTK targetengine. In the blow example this is not the case.
myName = "Bloggs";
myName || (myName = "Smith"); // will not get set to "Smith" because a value has already been allocated
alert(myName); // >= Bloggs
myName = null;
myName || (myName = "Trevor"); // will get set to "Smith" because myName has no value
alert(myName); // >= Trevor
@ Marc, Thank you again for spending the time to script a solution, I learnt a lot from it and I'm sure it's more efficient than my one.
Trevor