What is the Difference Between "unknown" and "any" Types in TypeScript?

In TypeScript, both any and unknown types can represent any value, but they differ in type safety:

In summary, use unknown when you want a variable to accept any value but still enforce type safety, and use any when you need maximum flexibility without type checks.