Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
becki:linux:javascript [2011-03-08 07:08] becki |
becki:linux:javascript [2011-03-21 17:04] (aktuell) becki |
||
---|---|---|---|
Zeile 128: | Zeile 128: | ||
</code> | </code> | ||
- | Seems to cause overhead, see http://phrogz.net/JS/Classes/OOPinJS.html | + | * Seems to cause overhead, see [[http://phrogz.net/JS/Classes/OOPinJS.html|OOP in JS, Part 1 : Public/Private Variables and Methods]] |
+ | * This is callad a privileged method (which has access to private methods, see below) | ||
=== External method definition and link to object inside of the constructor == | === External method definition and link to object inside of the constructor == | ||
Zeile 159: | Zeile 160: | ||
Seems to be the **best** solution :-) | Seems to be the **best** solution :-) | ||
- | ==== Access Types ==== | + | ==== Public Access == |
<code javascript> | <code javascript> | ||
Zeile 194: | Zeile 195: | ||
</code> | </code> | ||
- | Private methods seem to be only possible as inline constructor functions, but those seem to cause overhead. | + | ==== Public Access == |
+ | |||
+ | Private methods are possible as inline constructor functions: | ||
+ | |||
+ | <code javascript> | ||
+ | function MyClass() { // The constructor | ||
+ | var privateVariable= 10; // A private instance variable | ||
+ | var privMeth1= function {...} // A private method | ||
+ | fuction privMeth2 {...} // private method (shortcut) | ||
+ | var that= this; // To make this available for priv methods | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Notes: | ||
+ | * Private methods possibly cause overhead, compared to the prototype way of public methods | ||
+ | * ''this'' seems only to be accessible in private methods by the ''that'' workaround variable above | ||
+ | * Public methods defined with the (recommended) ''prototype''-way doesn't seem to have access to private mehtods. You need privileged methods (see above) for that. | ||
+ | |||
+ | Sources & more information: | ||
+ | * [[http://javascript.crockford.com/private.html|Private Members in JavaScript]] | ||
+ | * [[http://phrogz.net/JS/Classes/OOPinJS.html|OOP in JS, Part 1 : Public/Private Variables and Methods]] | ||
==== Inheritance == | ==== Inheritance == | ||
Zeile 203: | Zeile 224: | ||
* [[http://dojotoolkit.org/book/dojo-book-0-4/part-3-dojo-programming-model/global-dojo-objects|Using objects to simulate a namespace]] | * [[http://dojotoolkit.org/book/dojo-book-0-4/part-3-dojo-programming-model/global-dojo-objects|Using objects to simulate a namespace]] | ||
+ | |||
+ | ===== Constants == | ||
+ | |||
+ | ''const'' is mentioned in the [[https://developer.mozilla.org/en/JavaScript/Guide/Values%2c_Variables%2c_and_Literals#Constants|Mozilla guide]] but dosen't work with Rhino version :?: and probabaly neither with IE | ||
===== Events == | ===== Events == | ||
Zeile 374: | Zeile 399: | ||
See [[jrunscript]] | See [[jrunscript]] | ||
- | ===== Todo == | ||
- | * Intro to [[https://www.ibm.com/developerworks/xml/tutorials/x-jquerymobilejsontut/|JQM]] (jQuery Mobile) |