Skip to content

Instantly share code, notes, and snippets.

@devded
Created May 22, 2022 19:42
Show Gist options
  • Save devded/d1715a425b679744addb231d6f2dd119 to your computer and use it in GitHub Desktop.
Save devded/d1715a425b679744addb231d6f2dd119 to your computer and use it in GitHub Desktop.
data = [
{
id: 1,
name: null,
price: 1,
},
{
id: "2",
name: "Nike",
price: "",
},
];
// check data array object is not empty
for (var i = 0; i < data.length; i++) {
console.log(data[i]);
const isEmpty = Object.values(data[i]).some((x) => x === null || x === "");
console.log(isEmpty);
console.log("Object key cannot be empty or null");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment