The Apply() Method : Inheritance : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Inheritance »

 

The Apply() Method









The apply() method takes two arguments.

The first one is the object to be used for this.

The second one is an array of arguments to be passed to the function.








function sayColor(sPrefix, sSuffix) {
    alert(sPrefix + this.color + sSuffix);
};

var obj = new Object();
obj.color = "red";

sayColor.apply(obj, new Array("The color is ",", a very nice color indeed."));







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Inheritance