#1 Using
Example:
instanceof
operator #Example:
Additional
Checking object #
This operator can also check if the input is an object, by usingObject
built-in constructor. As such:
Or, we can usetypeof
method.
For example:typeof
will return "object" (string) keyword for eitherobject
orarray
type input. Therefore, this operator can't be used for checking "array" input.
Checking function #
We can check whether an object is a function:
Or, usingtypeof
operator.
For example:
Checking string and number #
We can usetypeof
for those.
As such:
Checking element #
We can useinstanceof
for that.
Example:
No comments:
Post a Comment
Tell me what you think...