Przerabiam kurs na udemy z angularem (https://www.udemy.com/course/the-complete-guide-to-angular-2/)
Mam dany model, np.
Car {
brand: string;
}
Serwis, który zwraca tablicę Car[]
getCars(): Car[] {
return this.cars.splice();
}
Jak widać, zwróciłem kopię mojego obiektu cars, autor powiedział, że mimo tego nie jest błędem zwrócić this.cars
.
Zastanawiam się czy to nie jest trochę overengineering autora bo jeszcze w back-endzie mogę zrozumieć. Jaką macie opinie na ten temat?