Monday, 31 August 2015

javascript clear an array

1. most of time you can do array=[] to reset and clear the array.

2. Sometime you just can't directly reset it. because you are using the reference, in that case, you can:

array.length=0. but this doesn't support all bowsers.

The best solution i suggest to do is:

array.splice(0, array.length);

No comments:

Post a comment