Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Liquid Web Managed Dedicated Server: RAID 1 SSD with 16GB of RAM minimum! 24/7 On-Site Heroic Support! Industry-Leading SLA!

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Liquid Web Cloud VPS Hosting

8,367 questions

11,628 answers

573 users

How to use call in JavaScript

2 Answers

0 votes
var worker1 = {name: 'Holly', age: 33, from: 'NY'};
var worker2 = {name: 'Molly', age: 31, from: 'LA'};

var workerDetails = function()
{
    document.write(this.name + ' ' + this.age + ' ' + this.from + '<br />');
};


workerDetails.call(worker1);
workerDetails.call(worker2);


/*
run:
  
Holly 33 NY
Molly 31 LA
    
*/

 




answered Jul 27, 2015 by avibootz
0 votes
document.write(this + '<br />'); // the object Window


var worker1 = {name: 'Holly', age: 33, from: 'NY'};
var worker2 = {name: 'Molly', age: 31, from: 'LA'};

var workerDetails = function()
{
    document.write(this.name + ' ' + this.age + ' ' + this.from + '<br />');
    document.write(this + "<br />"); // our object worker1 and worker2 
};


workerDetails.call(worker1);
workerDetails.call(worker2);


/*
run:
  
[object Window]
Holly 33 NY
[object Object]
Molly 31 LA
[object Object]
    
*/

 




answered Jul 27, 2015 by avibootz
...