Typescript / Javascript: String IsNullOrEmpty

Date: 2021-09-22
export const stringIsNullOrEmpty = (str) => {
    if (typeof str !== "string") return true;
    if (str.trim().length < 1) return true;
    return false;
};
export const stringIsNullOrEmpty = (str: any) => {
    if (typeof str !== "string") return true;
    if (str.trim().length < 1) return true;
    return false;
};

export const stringHasValue = (str: any) => !stringIsNullOrEmpty(str);

/*
export const stringHasValue = (str: any) => {
    if (typeof str !== "string") return false;
    if (str.trim().length < 1) return false;
    return true;
}
*/
53640cookie-checkTypescript / Javascript: String IsNullOrEmpty