js performance question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

js performance question

Jean-Baptiste BRIAUD -- Novlog
Hi the list !

What would you recommend me to choose between :
1.
anInstance.index1 = ...
anInstance.index2 = ...

2.
anInstance["index1"] = ...
anInstance["index2"] = ...

On both I can iterates on indexes, I can have direct access to any  
value given a key.
There is no conceptual things here, just various object to store at  
some keys.
It doesn't matter that 1. is class's attributes and 2. array's value.

So I guess the last thing to decide is performance : witch one is  
better ?

Thanks !


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: js performance question

Fabian Jakobs
Administrator
Jean-Baptiste BRIAUD -- Novlog schrieb:

> Hi the list !
>
> What would you recommend me to choose between :
> 1.
> anInstance.index1 = ...
> anInstance.index2 = ...
>
> 2.
> anInstance["index1"] = ...
> anInstance["index2"] = ...
>
> On both I can iterates on indexes, I can have direct access to any  
> value given a key.
> There is no conceptual things here, just various object to store at  
> some keys.
> It doesn't matter that 1. is class's attributes and 2. array's value.
>
> So I guess the last thing to decide is performance : witch one is  
> better ?
>
> Thanks !
>
>  
The first one is faster because the JS engine does not have to create a
string instance and does not have to do a string compare.

Fabian

--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
Telefon: +49 721 91374-6784
[hidden email]

Amtsgericht Montabaur / HRB 6484
Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel