<html> <head> <script> function demo1() { let fruits = ["Apple", "Banana", "Chikoo", "Guava"] document.write(fruits) document.write("<br>"+fruits[0]) let f1 = fruits[4] document.write("<br>"+f1) //get all data of array one by one for(i=0;i<=3;i++) { document.write("<br>"+i+fruits[i]) } //change value at a position in array fruits[2] = "Mango" document.write("<br>"+fruits) fruits.push("PineApple") document.write("<br>"+fruits) fruits[5]="Orange" document.write("<br>"+fruits) document.write("<br> Count "+ fruits.length) //insert new element in between fruits.splice(3, 0, "Graps") document.write("<br>"+fruits) //remove from Last let f2 = fruits.pop() document.write("<br>Removed from array "+f2) document.write("<br>"+fruits) //remove element from a position fruits.splice(4,1) document.write("<br>"+fruits) } </script> </head> <body> <input type="button" value="Go" onclick="demo1()"/><br> </body> </html>
Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore
contact@codebetter.in
+91 88230 75444, +91 99939 28766