Complete the code to define a simple DTO class in Express.
class UserDTO { constructor(user) { this.id = user.[1]; } }
The DTO class copies only the id property from the user object to transfer minimal data.
Complete the code to create a DTO instance from a user object.
const userDTO = new UserDTO({ id: 1, name: 'Alice', email: 'alice@example.com' });
console.log(userDTO.[1]);The DTO instance exposes the id property, which was copied from the user object.
Fix the error in the DTO class to correctly assign the email property.
class UserDTO { constructor(user) { this.email = user.[1]; } }
The user object property is named email, so the DTO must use the same name to assign it correctly.
Fill both blanks to create a DTO that includes id and email from the user object.
class UserDTO { constructor(user) { this.[1] = user.id; this.[2] = user.email; } }
The DTO copies id and email properties to transfer only necessary data.
Fill all three blanks to create a DTO that includes id, name, and email from the user object.
class UserDTO { constructor(user) { this.[1] = user.id; this.[2] = user.name; this.[3] = user.email; } }
The DTO copies id, name, and email properties to transfer user data safely without sensitive info.