verifying the correctness and utility of my isEmpty() function

""

by Matt Rummler

JavaScript

alert('@ the beginning');
var TestObject={testZero:0,testIsString:'1st',testIsNull:null,testIsEmptyStr:'',testInt:1,testEmptyArray:[]};

Object.toType = (function toType(global) //taken from https://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
{
  return function(obj) 
  {
    if (obj === global) 
    {
      return "global";
    }
    return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
  };
})(this);

function isEmpty(valueToTest)
{
//    alert('at the beginning of isEmpty()');
    if(valueToTest)
    {
//        alert('the valueToTest in isEmpty() has a value');
        if(Object.toType(valueToTest)=='array')
        {
            if(valueToTest.length <1)
            {
//                alert('about to return true from isEmpty()');
                return true;
            }
        }
        else if(Object.toType(valueToTest)=='object')
        {
            if(Object.keys(valueToTest).length <1)
            {
//                alert('about to return true from isEmpty()');
                return true;
            }
        }
//        alert('about to return false from isEmpty()');
        return false;
    }
    else
    {
//        alert('about to return true from isEmpty()');
        return true;
    }
}

function returnEmptyStatus(propertyValue,propertyName)
{
//    alert('at the beginning of returnEmptyStatus()');
  propertyName=propertyName || 'No property name was passed';
  if(isEmpty(propertyValue))
  {
      alert('The value of TestObject.'+propertyName+' has resolved as empty from isEmpty()');
  }
  else
  {
      alert('The value of TestObject.'+propertyName+' has resolved as NOT empty and has the following value: '+propertyValue);
  }
}

//1st test = zero test
var tested=TestObject['testZero'];
returnEmptyStatus(tested,'testZero');
//2nd test = string test
var tested=TestObject['testIsString'];
returnEmptyStatus(tested,'testIsString');
//3rd test = null...