我如下创建JavaScript class
:
class contact{
constructeur(nom,prenom){
this.nom = nom;
this.prenom = prenom;
}
function afficher(){
return "Nom : " + this.nom + "Prenom : " + this.prenom;
}
...
但是我在jslint Excepted an identifier saw 'class'
中有错误
并且在eslint中给出the keyword 'Class' is reserved
的错误
您的代码存在一些问题:
constructor
拼写错误function
关键字。class Contact {
constructor (nom, prenom) {
this.nom = nom;
this.prenom = prenom;
}
afficher () {
return "Nom : " + this.nom + " Prenom : " + this.prenom;
}
}