<!DOCTYPE html>
<html>
<body>
<h2>JavaScript関数</h2>
<p>この例では、person の fulllName メソッドが person1 に<b>適用</b>されます。</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>