in JavaScript by

What will be the output of the following JavaScript code?

<script>  

var string1=[1,2,3];  

  

var string2=[4,5,6,7,8,9,10];  

var result=string1.concat(string2);  

document.writeln(result);  

</script>
  

a) 1, 2, 3

b) Error

c) It will concatenate both the stings and print as 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10

d) It will print nothing

1 Answer

0 votes
by

Answer: C

Reason: In JavaScript, the "concat()" is a predefined method which is used to join the values of two arrays. Both the arrays can contain string or the integers.

Example

<script>
var val1=[1,2,3];  
var val2=["G,O"];  
var result=val1.concat(val2);  it will join values of both the array and store in the "result" variable
document.writeln(result);
</script>

Related questions

+1 vote
asked Mar 22, 2021 in JavaScript by Robindeniel
0 votes
asked Mar 21, 2021 in JavaScript by rajeshsharma
0 votes
asked Mar 24, 2021 in JavaScript by sharadyadav1986
...