运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Functions</h2> <p>In this example the fulllName method of person is <b>applied</b> on person1:</p> <p id="demo"></p> <script> const person = { fullName: function(city, country) { return this.firstName + " " + this.lastName + "," + city + "," + country; } } const person1 = { firstName:"John", lastName: "Doe" } document.getElementById("demo").innerHTML = person.fullName.apply(person1, ["Oslo", "Norway"]); </script> </body> </html>