Introduction
In JavaScript, there are situations when we need to check if an object is an array. In this article, we'll look at how to do it.
How to check if an object is an array
To check if an object is an array use Array.isArray(obj)
function:
Conclusion
In this article, we learned how to check if an object is an array. Luckily in modern browsers we have a dedicated method to do it, but in case our browser doesn't support the Array.isArray(obj)
method we could implement that function by ourselves:
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}