Two things:
1. JSON is a data transfer format. JSON data is stored in a string,
like this: '{"this": ["is", "a", "JSON", "string]}'. I think you're
talking about a JavaScript array.
2. I don't see any problem with keeping it in a global variable, as
long as you're sensible with how you access it.
Nick
On 29 September 2011 12:29, Brams <[email protected]> wrote:
> Hello,
>
> I've been researching this for quite a while now and I still didn't get a
> definitive answer on this.
>
> I have a huge JSON array that needs to be saved on my page. I will be
> extracting/looping/iterating over this array in certain cases when the user
> clicks on a specific button.
>
> Now I'm faced with two options on where to store this huge JSON array:
>
> 1- In a JavaScript global variable
> 2- Or using the $.data function and store the array under some DOM element
> i.e. $('body').data("my_array", {.....});
>
> Which is one is better? are they the same? is one slower over the other?
> what's the best practice in this case?
>
> Thanks in advance for your input guys!
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
--
Nick Morgan
http://skilldrick.co.uk
@skilldrick
Save our in-boxes! http://emailcharter.org
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]