Define a namespace (if you already haven't one) and store that array somewhere inside that namespace.
For instance: var BRAMS = BRAMS || {}; And then: BRAMS.data = /* your array */; On Sep 29, 1:29 pm, Brams <ibrahim.ba...@gmail.com> 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/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com