Return Json with the attributes of a class without "_" in the initials

0

I have this following javascript class:

class Usuario {
  constructor() {
    this._nome = '';
    this._idade = '';
  }


  get nome() {
    return this._nome;
  }

  set nome( value ) {
    this._nome = value;
  }

  get idade() {
    return this._idade;
  }

  set idade( value ) {
    this._idade = value;
  }
}

When I return it via json , it returns the names with _ at startup. I know this sign means that the attribute can only be used within the class itself, so I would like to return the attribute names without this character.

    
asked by anonymous 13.10.2018 / 20:06

0 answers