Better performance with javascript using Array, Object literal or JSON?

I am having a dilemma as I need to choose the best performing option.

What I have now is a simple array like:

var array = [

this array would contain around 60 options only but as I need to separate by language I am thinking of other options such as object literal or JSON format so it would contain all languages and around 1000 options.

var obj = {
            'en' : {
                'title' : 'bla',
                'url':'bla bla bla'                 
            'de' : {
                'title' : 'bla',
                'url':'bla bla bla'                 

The questions is what do you think would best perform for this? Thank you.


Object literal and JSON are the same thing (correction: see Quentin's comment)

IF you're searching for a value then JSON can have better performance because it's a hashmap implementation, so the lookup time would be O(1).

JSON is also more flexible, since you can have arrays in your JSON, you can have named keys, etc.

That said, I wouldn't worry about the performance gains here. They're probably negligible.

If you're trying to map your HTML pages to a language, you can either store the URL in a JSON keyed by language abbreviation ('en', 'de', etc.) or you could use a convention for naming your files (index-en.html, index-de.html). It's your choice.

Need Your Help

Can't cumulate the sum of array elements with VBA

arrays vba sum

I'm trying to cumulate the sums of values in an excel column of 4 values dimension (4,1).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.