clear an array using javascript

<html>
 <head>
  <title>clear an array using javascript</title>
 </head>
 <body style="background:lightgray">
  <p>Click the button to test:</p>
  <button onclick="test()">clear array</button>
  </br>
  <textarea id="edit" style="height:200px;width:240px">
  </textarea>
  <script>
  var arr=[1,2,3];
  function test() {
   clearArray(arr);
   document.getElementById("edit").value=arr;
  }
  function clearArray(arr) {
   arr.length=0;
  }
   document.getElementById("edit").value=arr;
  </script>
 </body>
</html>

Comments

Popular posts from this blog

How to write data into a excel file using vbscript

Format date as yyyy-mm-dd using vbscript