0 votes
in JavaScript by

Which one of the following codes is correct for concatenating the strings passed into the function?

A. Code 1

functionconcatenate()  

{  

returnString.prototype.concat('', arguments);  

}  

B. Code 2

functionconcatenate()  

{  

returnString.prototype.concat.apply('', arguments);  

}  

C. Code 3

functionconcatenate()  

{  

returnString.prototype.apply('', arguments);  

}  

D. Code 4

functionconcatenate()  

{  

returnString.concat.apply('', arguments);  

}  

1 Answer

0 votes
by

Answer: B

Reason: The "concat()" method is a predefined method of the JavaScript which is used for joining the two or more arrays. The significant advantage of using this method is instead of making changes in the existing array it returns a newly created array. The ".apply" method is also predefined method just like the" concat()", and it takes arrays of arguments and consider the every element of that array as an individual argument.

Related questions

0 votes
asked Mar 21, 2021 in JavaScript by rajeshsharma
0 votes
asked Mar 24, 2021 in JavaScript by sharadyadav1986
...