I am looking at the code to find out whether an object is an array on not, and I came across this answer.
The code is working fine, but I am not able to understand how it is performing a comparison with [object Array]
I tried to get the typeof Array
, but it's throwing an error. So I am confused with this code"
if( Object.prototype.toString.call( someVar ) === '[object Array]' ) {
I am interested to know how the toString.call( _ON_AN_ARRAY_ )
method call on an Object is correctly getting the type of an Array object.