object oriented javascript made easy | call() and apply() in oojs

There is always something to learn everyday and You’ll never stop being surprised by JavaScript. There are lot of sites which explains about what is call() and apply() in JavaScript. This tutorial is for the beginners and a quick tip on how to use call() and apply().

Lets start with definition

call() and apply() are predefined JavaScript function methods. Both methods can be used to invoke a function, and both methods must have the owner object as first parameter.

Lets create two Objects teamIndia and teamPakistan

var teamIndia={
alert(this.name+' we lost the worldcup 2015');

var teamPakistan={

How do we invoke message residing in teamIndia object from teamPakistan object?
We can use call() here

Hope this helps


I Am suresh(suresh kumar )a Web developer,Freelancer,webdesigner,UI developer from bangalore. Got 6+ yrs of IT experience . I specialize in standards-based XHTML, CSS and JavaScript web development. Each site I develop is built to be search engine friendly (SEO), using the latest development principles and techniques.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *