It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum Script-archive

PHP's Empty Function for Javascript

PHP's Empty Function for Javascript

Postby HotNoob on Fri Sep 24, 2010 4:56 pm

Code: Select all
function empty (mixed_var)
   {
    var key;
    if (mixed_var === "" ||
        mixed_var === 0 ||
        mixed_var === "0" ||
        mixed_var === null ||
        mixed_var === false ||
        typeof mixed_var === 'undefined')
    {
        return true;
    }
    if (typeof mixed_var == 'object')
     {
        for (key in mixed_var)
         {
            return false;
        }       
         return true;
    }

    return false;
}

this function determines if a variable is empty, which can be quite useful.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am

Who is online

Users browsing this forum: No registered users and 0 guests