Write a JavaScript to create array and perform various operations on array.
Solution:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JS - Arrays</title>
</head>
<body>
<script type="text/javascript">
var ary1 = new Array(5,10,15,20);
document.write("Array1 is : "+ary1);
var ary2 = new Array(25,30,35);
document.write("<br>Array2 is : "+ary2);
var ary3 = ary1.concat(ary2);
document.write("<br>After Concatinate Array3 is : "+ary3);
document.write("<br>Index of element 30 in Array3 is : "+ary3.indexOf(30));
ary3.push(40);
document.write("<br>Push an element 40 in Array3 is : "+ary3);
document.write("<br>Popped element from Array3 is : "+ary3.pop());
document.write("<br>Array3 is : "+ary3);
</script>
</body>
</html>
Output:<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JS - Arrays</title>
</head>
<body>
<script type="text/javascript">
var ary1 = new Array(5,10,15,20);
document.write("Array1 is : "+ary1);
var ary2 = new Array(25,30,35);
document.write("<br>Array2 is : "+ary2);
var ary3 = ary1.concat(ary2);
document.write("<br>After Concatinate Array3 is : "+ary3);
document.write("<br>Index of element 30 in Array3 is : "+ary3.indexOf(30));
ary3.push(40);
document.write("<br>Push an element 40 in Array3 is : "+ary3);
document.write("<br>Popped element from Array3 is : "+ary3.pop());
document.write("<br>Array3 is : "+ary3);
</script>
</body>
</html>