<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Expressing IT &#187; Prototype</title>
	<atom:link href="http://developer.expressionz.in/blogs/tag/prototype/feed/" rel="self" type="application/rss+xml" />
	<link>http://developer.expressionz.in/blogs</link>
	<description>User Interface : just another, but a serious developers weblog</description>
	<lastBuildDate>Thu, 20 May 2010 18:05:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Remove specific item from a javascript array that matches a passed string</title>
		<link>http://developer.expressionz.in/blogs/2008/09/01/javascript-array-remove-specifc-item/</link>
		<comments>http://developer.expressionz.in/blogs/2008/09/01/javascript-array-remove-specifc-item/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 11:18:32 +0000</pubDate>
		<dc:creator>Nikhil</dc:creator>
				<category><![CDATA[JavasScript]]></category>
		<category><![CDATA[UI Developer]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[String Trim]]></category>

		<guid isPermaLink="false">http://developer.expressionz.in/blogs/?p=32</guid>
		<description><![CDATA[
			
				
			
		
Here&#8217;s quick way of extending the native Javascript Array Object, just to do that&#8230;
Array.prototype.removeItem=function(str) {
   for(i=0; i&#60;this.length ; i++){
     if(escape(this[i]).match(escape(str.trim()))){
       this.splice(i, 1);  break;
     }
   }
  return this;
}

So now you can do something like this&#8230;
var animals= new Array("dog","lion","cat","tiger","elephant");
animals.removeItem('tiger');
Now the animals array will contain &#8220;dog&#8221;,&#8221;lion&#8221;,&#8221;cat&#8221;,&#8221;elephant&#8221;;
 PS: And here is the String Trim Prototype too &#8230;
String.prototype.trim=function(str) {
  [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F09%2F01%2Fjavascript-array-remove-specifc-item%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F09%2F01%2Fjavascript-array-remove-specifc-item%2F&amp;source=nikhild&amp;style=normal&amp;hashtags=Array,Prototype,String+Trim" height="61" width="50" /><br />
			</a>
		</div>
<p>Here&#8217;s quick way of extending the native Javascript Array Object, just to do that&#8230;</p>
<blockquote><p><code>Array.prototype.<strong>removeItem</strong>=function(str) {<br />
   for(i=0; i&lt;this.length ; i++){<br />
     if(escape(this[i]).match(escape(str.trim()))){<br />
       this.splice(i, 1);  break;<br />
     }<br />
   }<br />
  return this;<br />
}<br />
</code></p></blockquote>
<p>So now you can do something like this&#8230;</p>
<blockquote><p><code>var animals= new Array("dog","lion","cat","tiger","elephant");<br />
animals.<code>removeItem</code>('tiger');</code></p>
<p>Now the animals array will contain &#8220;dog&#8221;,&#8221;lion&#8221;,&#8221;cat&#8221;,&#8221;elephant&#8221;;</p></blockquote>
<p> PS: And here is the String Trim Prototype too &#8230;</p>
<blockquote><p><code>String.prototype.trim=function(str) {<br />
  str = this != window? this : str;<br />
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');<br />
}</code></p></blockquote>
<p> <br />
Enjoy&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://developer.expressionz.in/blogs/2008/09/01/javascript-array-remove-specifc-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
