const isFalsy = (value) => {
const isUndefined = value === undefined;
const isNull = value === null;
const isEmptyString = typeof value === "string" && !value.trim();
const isEmptyArray =
typeof value === "object" && Array.isArray(value) &&
value.length === 0;
const isEmptyObject =
typeof value === "object" &&
!Array.isArray(value) &&
Object.keys(value).length === 0;
return (
isUndefined || isNull || isEmptyString ||
isEmptyArray || isEmptyObject
);
};
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Twitter β Facebook
Micro-Learning β Web Development β Javascript β MERN stack β Javascript
codedrops.tech
Top comments (0)