is_array() function for Javascript

To check whether variable array or not need to use type check syntax: instanceof:

[] instanceof Array // true
'string' instanceof Array // false

You can make a function to incapsulate the feature:

function is_array(variable) {
	return variable instanceof Array


is_array([]) // true
is_array('string') // false

jQuery also has the similar function:

$.isArray([]) // true

Books to read

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">