Question

I have an array which contains objects, these objects are in the same order and correspond to the li's of a ul.

I was wondering if there was any negligible difference between doing:

(this.element is the ul's)
this.element.children(".tagit-choice:last").remove();
vs
(this.tagsArray is the array of objects about the li's)
this.tagsArray[this.tagsArray.length -1].element.remove();

or is there a better way (noting that when this is called tagsArray will always have something in it, so getting an index of -1 is not an issue)?

Was it helpful?

Solution

Choose the more readable and maintable option:

.children(".tagit-choice:last").remove();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top