- What are the five primitive types?
- string: Represents a sequence of Unicode characters
- number: Represents both integers and floating-point numbers
- boolean: Represents a logical true or false
- undefined: Represents a value that hasn't been initialized yet
- null: Represents no value
- What will the inferred type be for the flag variable be in the following code?
const flag = false;
flag will be inferred as the boolean type.
- What's the difference between an interface and a type alias?
The main difference is that type aliases can't be extended or implemented from, like you can with interfaces.
- What is wrong with the following code?
class Product {
constructor(public name: string, public unitPrice: number) {}
}
let table = new Product();
table.name = "Table";
table.unitPrice = 700;
The constructor requires name and unitPrice...