• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in JavaScript by
Q:

Which one of the following options is the correct output for the given code of JavaScript?

function code(id,name)  

{  

        this.id= id;  

        this.name= name;  

}  

functionpcode(id,name)  

{  

        code.call(this,id,name);  

}  

document.writeln(newpcode(004,"James Deo").id);  

a) James Deo

b) compilation error

c) runtime error

d) undefined

1 Answer

0 votes
by

Answer: A

Reason: The "call()" method mentioned in the above given piece of code, is used of calling a function in which the "this" is passed as an argument. It returns the output given by the calling function.

Related questions

0 votes
asked Mar 23 in JavaScript by sharadyadav1986
+1 vote
asked Mar 22 in JavaScript by Robindeniel
...