Using the unknown type

In this lesson, we will learn about the 'unknown' type; it is similar to the 'any' type but is type-safe.

An any type refresher

We learned from a previous lesson that the any type could be used when we are unsure of the type of value. The problem with any is that no type checks will be carried out on values of type any.

What if there was a type like any that can be used for values we don’t know but was also type-safe? This is what the unknown type is!

Get hands-on with 1200+ tech skills courses.