Check property with hasOwnProperty method - Javascript Object

Javascript examples for Object:Object Property

Description

Check property with hasOwnProperty method

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/* w  w w. j  ava 2  s. c o m*/
function getKeys(obj) {
    var keys = [],
        i;
    for (var i in obj) {
        if (obj.hasOwnProperty(i)) {
            keys.push(i);
        }
    }
    return keys;
}
console.log(getKeys({TEST: "abc"}));
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials