I'm kind of new to classes and Object Oriented programming. I'm working on improving my skills, so I want to learn how they work.
Let's say I'm making a REST API with the following model:
// user.js
module.exports = {
firstName: "",
lastName: "",
email: ""
}
Question 1: How would I convert something like this^ into a typescript class? And how would I call it in another file?
Let's say I've got this:
// user.js
class User { ... }
Question 2: When I execute an request on the API I get 20 SQL results back, would doing this:
// user-manager.js
import User from "./User";
users.forEach(user => {
const userTemplate = new User( ... );
});
cause a memory leak, because I'm calling new 20 times? How does this work?
Please help me out here..