comment définir une classe en JS
Bonjour, je suis en train de me mettre à la POO en js et je remarque que c'est pas tout à fait comme le java. Voici ma classe
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function Examen(studyInstanceUID, dateStudy, tabSerie)
{
var studyInstanceUID ;
var dateStudy;
var tabSerie=new Array;
this.studyInstanceUID =studyInstanceUID;
this.dateStudy=dateStudy;
this.tabSerie=tabSerie;
this.getStudyInstanceUID=function()
{
return studyInstanceUID;
}
this.getDateStudy=function()
{
return dateStudy;
}
this.getTabSerie=function ()
{
return tabSerie;
}
} |
mais j'ai vu dans les tutos que les variables d'instances n'étaient pas déclarées comme je l'ai fait
Code:
1 2 3
| var studyInstanceUID ;
var dateStudy;
var tabSerie=new Array; |
mais directement initialisées je veux savoir si il faut les déclarer avant de les initialiser où non?
Merci