JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Function Right Arrow call()

call()  Function  instance method


Calls a function with a given this value and arguments provided individually.


Signature Description[, arg1[, arg2[, ...argN]]])Calls a function with a given this value and arguments provided individually.


Parameter Description
thisArgThe value of this provided for the call to the function.
arg1,arg2,...argNThe arguments with which the function should be called,null or undefined if no arguments required.


Below is an example of using the call() method for chaining.

 / Create an anonymous function expression that takes an argument and 
 / returns the square of the argument.
function Country(name, capital) { = name; = capital;
  return this;
function County(name, capital, county) {, name, capital);
  this.county = county;
County.prototype = new Country();
// Define custom override function for County toString().
County.prototype.toString = function CountyToString() {  
  var county = + ' ' + + ' ' + this.county;  
  return county;  
function Town(name, capital, county, town) {, name, capital, county); = town;
Town.prototype = new County();
// Define custom override function for Town toString().
Town.prototype.toString = function TownToString() {  
  var town = + ' ' + + ' ' + 
             this.county + ' ' +;  
  return town;  
var essex = new County('England', 'London', 'Essex');

var barking = new Town('England', 'London', 'Essex', 'Barking');

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 8 - Functions


go to home page Homepage go to top of page Top