[Javascript] Form focus

Nick Fitzsimons nick at nickfitz.co.uk
Tue May 11 09:47:45 CDT 2004


On 11/5/04 2:39 pm, "Chris T" <christ at saeweb.com> wrote:

>> No, JScript arrays shouldn't be stored in Application scope within ASP. In
>> my experience, their contents tend to vanish when you try.
> 
> That sounds odd.  We regularly store Arrays in Application variables and it
> works great. Never had a problem. Of course these are VBScript arrays, but
> an Application variable is an application variable no matter what language
> it's in - or at least I was always under that impression.

The key point is that single-threaded apartment objects (which includes
JScript types such as Array) can't be stored in Application scope. VB arrays
are not of the same type as Jscript arrays (hence the VBArray class for
accessing them from JScript). See

http://support.microsoft.com/default.aspx?scid=kb;[LN];255887 and
http://support.microsoft.com/default.aspx?scid=kb;EN-US;255769 for details.

Microsoft's Eric Lippert (who wrote VBScript) has a detailed explanation of
what should and shouldn't go in Application or Session scope (and why) at

http://blogs.msdn.com/ericlippert/archive/2003/09/18/53050.aspx

where he says: "JScript arrays are objects... VBScript arrays are not
objects... but even still, you shouldn't put them in Session [or
Application] scope either... arrays are stored into and passed out of
Session [or Application] scope using our old friend  copy-in-copy-out
semantics.  That means  that every  single time you index into an array in
Session scope, a  copy of the array is made first.  If  that array is big,
that's a big performance problem."

Regards,

Nick Fitzsimons.




More information about the Javascript mailing list