Is there any difference in JS between
class a{
constructor(){
this.something=“blah balh”
}
}
And just
class a{
something=“blah blah”
}
I know i need a constructor when i pass specific data for the new instance. But when the data is the same for all instances, is there any difference between these 2 ways? Should i use one of them over the other?
Aucun commentaire:
Enregistrer un commentaire