OOP mit JavaScript
Version vom 12:24, 7. Sep. 2010 bei Monettenom (Diskussion | Beiträge)
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;
}
|