Skip to main content

Check if a particular value is empty in JavaScript.

/**
 * Check if a particular value is empty.
 *
 * @param {Mixed} val The value to check.
 * @return {Boolean} true if the value is empty, otherwise false.
 */
function isEmpty(val) {
    return typeof val === "undefined" || !val || 0 === val.length;
}