4 examples of 'has own property' in JavaScript

Every line of 'has own property' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
75export function ownProperty(obj, key) {
76 if (hasOwn(obj, key)) {
77 return obj[key];
78 } else {
79 return undefined;
80 }

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

42function ownProp (object, key) {
43 return Object.hasOwnProperty.call(object, key)
76function ownProp(o,p){return Object.prototype.hasOwnProperty.call(o,p)}
12export function getOwnProperty(object, key) {
13 return object.hasOwnProperty(key) ? object[key] : undefined

Related snippets