Home
<!DOCTYPE html> <html> <body> <h1>Demo: JavaScript Object</h1> <p id="p1"></p> <script> var person = new Object(); if(person.hasOwnProperty("firstName")){ document.getElementById("p1").textContent = person.firstName; } else{ document.getElementById("p1").textContent = "No firstName property exists"; } </script> </body> </html>
Result: