To remove an item from Array, you need to call Array.splice().
I just feel that I can ease myself from memorizing this function name by adding "removeItem" function to the Array prototype like this:
if (!('removeItem' in Array.prototype)) {
Array.prototype.removeItem = function (i) { this.splice(i, 1); };
}
So, next time when you want to remove an item from array, just call removeItem().
For example,
var a = [ "apple", "banana", "orange" ];
a.removeItem(1);
Then, "banana" will be removed from the array.
Subscribe to:
Post Comments (Atom)
We are moving
We are moving this blog to our new blog site: https://ciysys.com/blog/nodejs.htm
-
Overview Usually, we start developing a new system with designing database and then writing codes. If you are not a fan of ORM, you will h...
-
Below is the sample HTML which will hide the URL at the page header when printing with Javascript. <html moznomarginboxes > ...
-
You can draw a simple pie chart & doughnut chart with SVG + CSS. This is quite simple and straight forward. But the limitation is that i...
No comments:
Post a Comment