InterviewSolution
Saved Bookmarks
| 1. |
What is meant by type inference? |
|
Answer» TypeScript can infer the type of a variable when you don’t provide an EXPLICIT type. This is KNOWN as type inference. This is usually done when the variables or parameters are INITIALIZED during the declaration. For example, TypeScript knows that the variable FOO is a string, even THOUGH we don’t mention string as a type. let foo = "this is a string";console.log(typeof foo); // "string" |
|