js performance question

View: New views
2 Messages — Rating Filter:   Alert me  

js performance question

by Jean-Baptiste BRIAUD -- Novlog :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: js performance question

by Fabian Jakobs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
fabian.jakobs@...

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
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel