Skip to main content
  1. Posts/

Crearing an array in JavaScript

Since it may be references to existing javascript array from other objects, the best way to clear array contents is assign its length to zero

:

var a = ['a', 'b', 'c']; //create some array
a.length = 0; // clear array