adithya.hebbar
Thu May 23 2024
In TypeScript interfaces,
#javascript #typescript
?:
denotes optional properties. Here's an example:
interface User {
name: string;
age?: number; // Optional
}
const user1: User = { name: "Joe Mama" }; // Age is optional
const user2: User = { name: "Tony", age: 30 };
console.log(user1); // Output: { name: "Joe Mama" }
console.log(user2); // Output: { name: "Tony", age: 30 }
#javascript #typescript