我创建如下的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
上的错误
答案 0 :(得分:0)
您的代码存在一些问题:
constructor
拼写错误function
关键字。/*jshint esversion:6 */
class Contact {
constructor (nom, prenom) {
this.nom = nom;
this.prenom = prenom;
}
afficher () {
return "Nom : " + this.nom + " Prenom : " + this.prenom;
}
}