Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

The Call() Method

The first argument of the Call() Method is the object to be used for 'this'. All other arguments are passed directly to the function itself. function sayColor(sPrefix, sSuffix) {     alert(sPrefix + this.color + sSuffix); }; var obj = new Object(); obj.color = "red"; sayColor.call(obj, "The color is ", ", a very nice color indeed. ");