Program:
Output:
<!DOCTYPE html> <html> <head> <script type='text/JavaScript'> var arr = new Array(); function pushItem() { var a = prompt("Enter any Number to push into array"); arr.push(a); document.getElementById("display").innerHTML = arr; } function popItem() { arr.pop(); document.getElementById("display").innerHTML = arr; } function revItem() { arr.reverse(); document.getElementById("display").innerHTML = arr; } </script> </head> <body> <button onclick ="pushItem()"> Push Item </button> <br/> <br/> <button onclick ="popItem()"> Pop Item </button> <br/> <br/> <button onclick ="revItem()"> Reverse Item </button> <br/> <br/> <h3 id="display"> </h3> </body> </html>
Output: