Use typeof algorithm
The operand of typeof is undefined, and the returned value is "undefined".
The following defines x as the operand:
There are five situations;
The operand is a number, typeof(x) returns "number";
String typeof(x) returns "string";
Boolean value typeof(x) returns "boolean";
Object, array, null: typeof(x) returns "object";
The function typeof(x) returns "function".
For example: