I am giving an example of typeof operator here. In this example I have an array with numeric and string values and I want to take total of only numeric values.
instanceof operator is good to know about the type of instance of value or variable. Suppose you have a multi-dimensional array with numeric values and want total of all those values then instanceof operator would be a right operator to use.
Please see the following example:
Important: You can check the variation in total by entering the different-2 values in above array too.
Note: Don’t increase the dimension of the array by entering another array in the nested array. You will not get total of those values as I haven’t used recursive array for the simplicity. If you want that too then please write in comment will tell you that too.
Lets instantiate Array in a variable i.e myArr.
var myArr = new Array();
Here myArr is the instance of Array object meaning all the properties and methods can be used on all the values inside this array through this instance. So if we have multiple objects instantiations and want to check for the instance then it is a good operator.