Example 1: Using instanceof Operator
Output
The variable is not of function type The variable is of function type
In the above program, the instanceof operator is used to check the type of variable.
Example 2: Using typeof Operator
Output
The variable is not of function type The variable is of function type
In the above program, the typeof operator is used with strict equal to === operator to check the type of variable.
The typeof operator gives the variable data type. === checks if the variable is equal in terms of value as well as the data type.
Example 3: Using Object.prototype.toString.call() Method
Output
The variable is not of function type The variable is of function type
The Object.prototype.toString.call() method returns a string that specifies the object type.