doekman / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

Adding Array.clear() #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What about a method that clears the array and removes all the items. 

At the moment I do:

base2.Javascript.bind(window);

if (!Array.prototype.clear) {
    Array.prototype.clear = function() {
        while (this.length > 0) {
            this.pop();
        }
    }
}

would be cool to have the clear() method also "done" with the bind
statement. Well neither do I know if there is such a method coming from
Mozilla nor if this completly usefull and array = []; is the better clear.

What do you think?

Original issue reported on code.google.com by unigossi on 26 Dec 2007 at 11:04

GoogleCodeExporter commented 9 years ago
I think that this is easier:

array.length = 0;

We don't need a method for this.

Original comment by dean.edw...@gmail.com on 26 Dec 2007 at 7:03