Skip to content

Instantly share code, notes, and snippets.

@sivaprabug
Last active March 10, 2016 10:33
Show Gist options
  • Select an option

  • Save sivaprabug/189d30a1c781e2ab8b7b to your computer and use it in GitHub Desktop.

Select an option

Save sivaprabug/189d30a1c781e2ab8b7b to your computer and use it in GitHub Desktop.
check hasOwnProperty in Javascript Class
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
o = new Object();
o.prop = 'exists';
function changeO() {
o.newprop = o.prop;
delete o.prop;
}
console.log(o.hasOwnProperty('prop'));
changeO();
console.log(o.hasOwnProperty('prop'));
o.prop = 'exists';
console.log(o.hasOwnProperty('prop'));
console.log(o.hasOwnProperty('toString'));
console.log(o.hasOwnProperty('hasOwnProperty'));
</script>
</head>
<body>
</body>
<!-- https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#Syntax gsivaprabu -->
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment