Should my classes’ atributtes be private in this specific case?

Viewed 20

Working with c++ in university, i was taught that classes’ atributtes should always be private and to access them i should use getters and setters. Now im working with JS, and i guess the same rules apply towards classes. But i’m facing a problem: Im building a webpage with nodejs, and i use express-handlebars. When i want to send an object with private attributes to the front end, express-hbs can’t access those attributes in the html, so my information is not displayed in front end. In html i cant use getters so i dont know how to access that information.

My question is: Should i make those attributes public and solve the problem the easy way? Should i keep them private and make copies of each private attribute using getters and then send those copies instead of the actual original object?

Thank you

0 Answers
Related