interface User {
    id: number;
    username: string;
    email: string;
}

const user: User = {
    id: 1,
    username: "JohnDoe",
    email: "johndoe@example.com"
};

console.log(user);
Bash

Explanation:

  • This program defines an interface User that describes the structure of a user object with three properties: id, username, and email.
  • The user variable is created based on the User interface, ensuring it has the correct properties.
  • The object is logged to the console, displaying the user information.
error: Content is protected !!
Scroll to Top
MacroNepal
Verified by MonsterInsights