using call function in javascript

Javascript function is  object which has their own properties and methods .One method that is available to each funtion object is call() which is defined on the prototype of the function .This method allow you to reuse a method from another object.

var podcast = {
 name : 'Astronomy podcast',
 download : function(episode) {
 console.log('Downloading ' + episode + ' of ' + this.name);
 }
};

podcast.download('the first episode');

var screencast = {
 name: 'Node tuts'
};

podcast.download.call(screencast, 'the last episode');

by calling the call method , we can reuse method download for screencast object.

Advertisements

About rahul23134654

Hi, I am Rahul Meha , B.E. in (I.T.)
This entry was posted in UI Js. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s