IsEmptyString function

function to test if a string is empty, null, or undefined

by burhans

JavaScript

function IsEmptyString(value)
{
    return (value == null ||
            value === "");
}

var someVariable;

function Check(message)
{
    if (IsEmptyString(someVariable))
        alert(message + "yes");
    else
        alert(message + "no");    
}

Check("smashy ");

someVariable = null;
Check("blam ");

someVariable = 1;
Check("kapow ");

someVariable = "";
Check("hoot ");