When I am trying to create a new object from the existing object as shown in below code i am unable to print the values from the duplicate object using JSON.stringify()
method. Unable to figure out what is the problem.
<!DOCTYPE html>
<html>
<body>
<p>Creating a JavaScript Object.</p>
<p id="demo"></p>
<script>
var person = {firstName:"John2", lastName:"Doe", age:50, eyeColor:"blue"};
var man = Object.create(person);
document.getElementById("demo").innerHTML =
man.firstName + " is " + man.age + " years old." + JSON.stringify(man);
</script>
</body>
</html>
Output I am getting is John2 is 50 years old. {}