August 1999
Intermediate to advanced
1488 pages
72h 53m
English
function.apply()The apply() method of the Function object is used to apply a method of one object to another object. Using the apply() method keeps developers from rewriting methods for different objects.
Listing 6.125 shows how the apply() method can be used between two objects. The bigHome function adds a new property, numRooms, to the home object.
<html> <body> <script lanuguage="JavaScript"> <!–– Hide // function defines a home with two properties function home(number, street){ var num = number; var str = street; document.write("house number is: " + num + "<br>"); document.write("Street ... |
Read now
Unlock full access