Type Checking with typeof
This lesson goes over type checking with JavaScript's typeof.
We'll cover the following...
Borrowing type
Borrowing the type of another variable is possible by using typeof
. Borrowing type brings protection at design time by allowing you to set a type without defining an actual interface or type. For example, you define a variable with some members using curly braces. There is no actual way to get the schema of the object.
However, with typeof
, you can extract the type from the variable. The extraction is possible for variables or parameters. Instead of a concrete type, the variable uses typeof
...