Given
var arr = [1,2,true,4,{\"abc\":123},6,7,{\"def\":456},9,[10]]
we can filter number items within array arr using N
There is no real way to do it safely without creating your own function. Additionally it is very complicated because the definition of Object is too broad.
Let's start with the following:
var types = ['1', 2, true, null, undefined, [], {}, new Date()];
and run the following:
types.map((e) => typeof e);
// ["string", "number", "boolean", "object", "undefined", "object", "object", "object"]
Do you think of null of as an Object? I don't think so. Do you think of an Array as of an Object, because the Array is an instance of Object? I am not sure as well.
What you can try is the following:
types.map(Object.isExtensible);
// [false, false, false, false, false, true, true, true]
This excludes the null from the result but still the array is present here. The Date Object is here as well as any other Object with any prototype, e.g. new Boolean() will also be an Object. Additionally the object could be frozen and this won't be returned as an Object here as well.
So the both examples here successfully demonstrate that the definition of Object is too broad and it cannot be really handled in a useful way.