PDA

View Full Version : [Solved] ext-base.js Array.remove returns undefined



MarkT
6 Aug 2007, 10:22 AM
I was testing version 1.1 and wanted to see how much work would be needed to drop Prototype in favor of the stand alone adapter. I use Prototype's Array.without feature in a few places to remove entries from an array. I tried using the Ext Array.remove function instead, and for the most part it worked the same.

The only difference was when I removed the last entry from the array. I was expecting it to return an empty array, but I got "undefined" instead.

My code looks something like this:


...
arr = arr.remove(val);
...

jack.slocum
6 Aug 2007, 6:12 PM
remove() does not return an array, it returns undefined every time. It is "in place" removal with no new array allocated.

MarkT
6 Aug 2007, 6:30 PM
Thanks. I looked at the source and noticed nothing being returned. I updated my code, removing the assignment to the variable and it is working now.