I like the way you can add methods/functions/members to built in JavaScript entities. The following adds a remove method to the Array object.
Array.prototype.remove = function(item_to_remove)
{
for (var i = 0; i < this.length; i++)
{
if (this[i] == item_to_remove)
{
this.splice(i,1);
break;
}
}
}
Anybody know a better way of removing items from an array?
Add New Comment
Viewing 11 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)