Monday, August 5, 2019

JavaScript Array undefined element

I´ve got a function which should add an element at the start of an array.
But I always get an undefined element at the end of my array. I hope someone can help me :)



function putToFirst(e){
var array = [];

array.push(e);
this.arrayList = array.concat(this.arrayList);
}


EDIT:



class List {

constructor () {

super()
this.arrayList = [];
}

putToFirst(e) {
this.ArrayList.unshift(e);
}
}



thats the class. I create a new object from the class list and call the function putToFirst on this object. But I always get an Array with 'undefinded' in the end

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...