Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Last active February 24, 2025 09:24
Show Gist options
  • Select an option

  • Save bhaireshm/b379722e38978cab80c639931001db64 to your computer and use it in GitHub Desktop.

Select an option

Save bhaireshm/b379722e38978cab80c639931001db64 to your computer and use it in GitHub Desktop.
Checks for the key in the given object. Can check multiple keys at once.
/**
* @param {Object} obj
* @param {String} keys : keys seperated by comma
* Example : console.log( hasOwnProperty({'a':1, 'b':2, 'c':3}, "a,d") );
*/
const hasOwnProperty = (obj, keys) => {
if(Object.entries(obj).length == 0 || keys.length == 0) return false;
else return keys.split(",").map((k) => {
if(k != "" && !Object.hasOwnProperty.call(obj, k)) return `${k} not found`;
}).filter(a=> typeof a == 'string')[0] || "All key(s) found";
};
@bhaireshm
Copy link
Copy Markdown
Author

ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment