<!DOCTYPE html> <html> <body> <h1>JavaScript 显示对象</h1> <p>JSON.stringify will not stringify functions.</p> <p>You have to convert functions to strings first:</p> <p id="demo"></p> <script> const person = { name: "Bill", age: function () {return 19;} }; person.age = person.age.toString(); document.getElementById("demo").innerHTML = JSON.stringify(person); </script> </body> </html>