is it an array?


/ Published in: JavaScript
Save to your folder(s)

Cribbed from Crockford's "JavaScript: The good parts."


Copy this code and paste it in your HTML
  1. var isArray = function(value) {
  2. return value &&
  3. typeof value === 'object' &&
  4. typeof value.length === 'number' &&
  5. typeof value.splice === 'function' &&
  6. !(value.propertyIsEnumerable('length'));
  7. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.