HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JSON hasOwnProperty()</h1> <button onclick="myFunction()">Click Me</button> <script> var data = [ { "name": "Mike", "age": 36, "married": true } ] function myFunction(){ console.log(data[0].hasOwnProperty("age")) console.log(data[0].hasOwnProperty("hair")) } </script> <p><strong>Note</strong>: Click on the button and check your console</p> </body> </html>
OUTPUT
×

Save as Private