Mobile and web design development (Android, iPhone, WordPress)
Google+TwitterLinkedinFacebook
Subscribe
HomeHTML, CSS & JavaScriptHow to check if a Javascript variable is an array

How to check if a Javascript variable is an array

Looking for the simplest way to check if a Javascript variable / object is an array? Here’s a simple way on how to check for an Array variable in javascript:

function isArray(variable) {
if (variable.constructor == Array)
return true;
else
return false;
}

or better yet, just do this:

function isArray(variable) {
return (variable.constructor == Array);
}

Leave a Reply

  • Hi, I'm Gerry. Welcome to my blog and sites about mobile, technology, The Pinoy, #crazyidea, games, WordPress, Ubuntu, Mac, iOS, Android, Symbian... I started sites like Ortigas Online and iMakati which focuses on local community information. Read more about Gerry
    Status (Twitter, Linkedin, Facebook...)

    Just found out that the Android-based HTC Sensation XL phone is now in the Philippines for about Php 28,000.

  • Visit my other sites

    • Gerry

      My blog about the Philippines, mobile, technology, games, mac, linux...

    • Apps & Games

      Reviews, news of mobile apps & games for Android, iOS, Blackberry, Symbian...

    • Connected Phone

      The computer is the mobile phone. The always connected phone evolution.

    • Pinoy Me

      Pinoy businesses, enterprises, startups, professionals all over the world

    • Java Midlet

      Java mobile apps & games - news, reviews, tips, mobile phone & devices

  • PINOI Sites

    Are you interested in putting up your own PINOI-enabled local community site? Contact me

    • PINOI

      Enabling local communities on the Internet

    • Makati

      iMakati.com is a site that provides information about Makati City.

    • Ortigas

      Community site that provides information about the Ortigas Center.