jadjoubran / codetogo.io

🚀 JavaScript code to go - Find updated snippets for common JavaScript use cases
https://codetogo.io
MIT License
233 stars 30 forks source link

Use Case Suggestion: How to check if an object is empty #254

Closed sevtapim closed 8 months ago

sevtapim commented 3 years ago

function isEmpty(obj) { return Object.keys(obj).length === 0; } //sample usage const john = { name: "John" }; isEmpty(john); // should return false isEmpty({}); // should return true

jadjoubran commented 8 months ago

Thank you! check if object is empty in JavaScript