Underscore and without is similar object

In next sample the object can be accessed as players or _players and is the same result ? Privacy meaning is for not change data recommedation

const team = {
_players : [
{firstName : ‘Juan’, lastName : ‘Gonzalez’, age : 76},
{firstName : ‘Juan’, lastName : ‘Perez’, age : 76},
get players() {
return this._players;
addPlayers(newFirstName,newLastName,newAge) {
let player = {
firstName : newFirstName,
lastName : newLastName,
age : newAge

Here, .players is a getter for ._players so both will access whatever is in ._players

1 Like

But in this case this.player it is getter is the property players. For that reason it is my doubt, in fact I make tests with _players and player and it worked.


isEmpty() function: It is used to check whether a list, array, string, object etc is empty or not . It first finds out the length of the passed argument and then decides. If length is zero, then the output is true otherwise false.