OOP mit JavaScript
(Unterschied zwischen Versionen)
(→Deklaration von Klassen) |
(→OOP mit JavaScript) |
||
| Zeile 1: | Zeile 1: | ||
| - | |||
| - | |||
== Einleitung == | == Einleitung == | ||
Dieses Tutorial basiert auf einen [http://phrogz.net/js/classes/OOPinJS.html Artikel] von Gavin Kistner und dessen [http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html Korrektur] durch Shelby H. Moore III. | Dieses Tutorial basiert auf einen [http://phrogz.net/js/classes/OOPinJS.html Artikel] von Gavin Kistner und dessen [http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html Korrektur] durch Shelby H. Moore III. | ||
Version vom 12:24, 7. Sep. 2010
Einleitung
Dieses Tutorial basiert auf einen Artikel von Gavin Kistner und dessen Korrektur durch Shelby H. Moore III.
Deklaration von Klassen
| PHP | C++ | JavaScript |
|---|---|---|
class Point2D
{
public $x;
public $y;
function __construct( $x = 0, $y = 0 )
{
$this->x = $x;
$this->y = $y;
}
}
|
class Point2D
{
public:
double x;
double y;
Point2D( double _x = 0, double _y = 0 )
{
x = _x;
y = _y;
}
};
|
function Point2D( x, y )
{
this.x = x ? x : 0;
this.y = y ? y : 0;
}
|