-2
class Servidor{
constructor(ip, port){
this.ip = ip
this.port = port
this.admin = true
}
getPropert(){
return { // o erro está aqui
this.port,
this.admin,
this.ip
}
}
}
My goal was to do the job getPropert
return an object with the value of class properties, however, I come across the following error:
this.port,
SyntaxError: Unexpected token '.'
in place of
self.id
placethis.ip
and consequently in others.– novic
Okay, I’ll do it.
– William Cardoso
I observed here, it was not to be self even, yet even with this, which refers to classse, it gives syntax error.
– William Cardoso
I believe it’s some kind of scope problem, but I can’t solve it.
– William Cardoso
is this to have scope in class and lacked
return {'ip' : this.id}
or{...this}
, creating an object without keys he is complaining ...– novic
thank you very much, I got by your comment.
– William Cardoso
recommended reading: https://answall.com/questions/201984/javascript-diff%C3%A7a-entre-this-e-self
– novic
I will read, thank you very much.
– William Cardoso