[英]Whey I have a problem to identify a class on javascript
我創建了一個如下所示的 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
的錯誤the keyword 'Class' is reserved
您的代碼存在一些問題:
constructor
拼寫錯誤function
關鍵字。/*jshint esversion:6 */
class Contact {
constructor (nom, prenom) {
this.nom = nom;
this.prenom = prenom;
}
afficher () {
return "Nom : " + this.nom + " Prenom : " + this.prenom;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.