Agregar parámetros opcionales JavaScript o TypeScript Función
function newsArticle(options: newsArticleOptions) {
const {
showHeadline = true,
showDate = true,
articleType = "World"
} = options;
}
// Use like this
newsArticle({ articleType: "Tech" });
// Of course, don't write JavaScript without TypeScript
interface newsArticleOptions {
showHeadline?: boolean
showDate?: boolean
articleType?: articleType
}
type articleType = "Tech" | "World" | "Sports"
night owl