Hi Dave,
in your eaxmple "foo" is a class variable. Technically everything you
add to the members section will be in the prototype of the class. That's
why obj.hasOwnProperty('foo') returns false whereas it returns true if
you set this in the constructor directly on "this".
As you have noted in the other mail you have to take care with maps or
arrays as values in the members section. They have copy by reference
semantics so each instance of the class will have a reference to the
same array/object. This is usually not expected. Primitive data types
like numbers, strings or booleans are no problem.
Best Fabian
> qx.Class.define("my.class", {
> ...
> members: {
> foo: 1
> }
> ...
> });
>
> In particular, when will foo be initialized? Is foo now an instance variable
> or a class variable?
>
> The reason I ask is that in some very complicated code I am seeing behavior
> that suggests foo is a class variable, not an instance variable. In other
> words, when I call obj.hasOwnProperty('foo'), where obj is an instance of
> class my.class, I get "false".
>
> In contrast, when I put this code in the constructor:
>
> this.foo = 1
>
> then each instance of my.class appears to get its own independent copy of
> foo.
>
> I'm wondering whether this is the advertised behavior, or whether something
> in my complicated code is causing QooxDoo to behave this way.
>
--
Fabian Jakobs
JavaScript Framework Developer
1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
Telefon: +49 721 91374-6784
[email protected]
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
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel