JavaScript Function Apply
Method Reuse With the apply() method, you can write a method that can be used on different objects. The JavaScript apply() Method The apply() method is similar to the call() method (previous chapter). In this example the fullName method of person is applied on person1: Example var person = { fullName: function() { return this.firstName + ” ” + this.lastName; } } var person1 = { firstName: “Mary”, lastName: “Doe”, } person.fullName.apply(person1); // Will return “Mary Doe” Try it […]
