运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Objects</h1> <h2>The Object.create() Method</h2> <p>Create a new object from the prototype of another project.</p> <p id="demo"></p> <script> // Create an Object: const person = { firstName: "John", lastName: "Doe", language: "EN" }; // Create new Object const man = Object.create(person); man.firstName = "Peter"; // Display Properties document.getElementById("demo").innerHTML = person.firstName + " and " + man.firstName; </script> </body> </html>