To empty an array in Javascript you can use the following methods.
Sample Javascript
myArray = [];
This code will set the variable A to a new empty array (take care if you have references to the “old” array).
or
myArray.length = 0
This will clear the existing array by setting its length to 0.
or
myArray.splice(0,myArray.length)
Working, but not recommended for this task. see Array.prototype.splice()
or
while(myArray.length > 0) { myArray.pop(); }
Fastest solution, without breaking references.
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…
RT @CodeSnippetsNET: How to empty an array in #Javascript http://t.co/nmlGY4yUHI #js #java #html #css #php #web #developer #dev #code #codi…