var a = new array();
a[1] = ‘A’;
b[10] = ‘B’;
console.log(a);
/[undefined, “A”, undefined, undefined, undefined, undefined, undefined, undefined,
undefined, undefined, “B”]/
I want to remove undefined element
but what is the process??
var a = new array(); a[1] = ‘A’; b[10] = ‘B’; console.log(a); / [undefined,
Share
First of all, jQuery has nothing to do with this.
Second, arrays are “autofilled”. If you define index
10, all indexes0–9will be occupied automatically, that’s just the way Javascript arrays work.What you’re looking for is probably an object:
or