- Assigning a new array:
myArray = [];
- Refactoring the current array:
myArray.length = 0;
The first method will assign a new array to the myArray variable. If there are any other pointers to the previous array, these will still point to the old array.
The second method changes the array itself. If there are any other pointers to the previous array, they will all be updated to the cleared array.
No comments:
Post a Comment