1Easytypes vs interfacesโฑ 35s
What is the key difference between type and interface in TypeScript?
โผ
What is the key difference between type and interface in TypeScript?
What does the 'any' type do in TypeScript?
What is the output type of this TypeScript function?
function greet(name: string) {
if (name.length > 5) {
return 'Hello, ' + name;
}
}What does the '?' (optional) operator do in a TypeScript interface?
interface User {
name: string;
age?: number;
}What is the difference between 'unknown' and 'any' in TypeScript?
What does the 'readonly' modifier do in TypeScript?
interface Config {
readonly apiUrl: string;
timeout: number;
}
const cfg: Config = { apiUrl: 'https://api.example.com', timeout: 5000 };
cfg.timeout = 3000; // ?
cfg.apiUrl = 'new'; // ?What is a union type in TypeScript?
function format(value: string | number): string {
return String(value);
}What is a type assertion in TypeScript and when should you use it?
const input = document.getElementById('name') as HTMLInputElement;
console.log(input.value);