How to duplicate elements of an array in the same array with JavaScript?



Following is the code to duplicate elements of an array in the same array −

Example

 Live Demo






Document



Duplicate elements of an array in the same array

[1,2,3,4,'A']

Click on the above button to duplicate the elements of the above array

Output

The above code will produce the following output −

On clicking the ‘CLICK HERE’ button −

Updated on: 2020-07-18T08:22:41+05:30

530 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements