C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Using shift and unshift to Add and Remove Elements using JavaScript


Posted Date: 11 Oct 2008    Resource Type: Code Snippets    Category: Javascript

Posted By: Bindu Bujji       Member Level: Gold
Rating:     Points: 5



The push() and pop() methods operate on the end of the array.
The shift() and unshift() methods perform the same function as push() and pop(), except in reverse.

The unshift() method adds an element to the beginning of an Array.

var friends = ["Net", "Giri"]
friends.unshift("Sastry");
alert(friends);


OUTPUT: Sastry,Net,Giri

Now the shift() which removes an element from the beginning of an Array.


var friends = ["Sastry", "Net", "Giri"]
friends.shift();
alert(friends);


OUTPUT: Net,Giri
(note friend "Sastry" been removed from the list since we used shift())







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using shift and unshift to Add and Remove Elements using JavaScript  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: PUSH POP in javascript
Previous Resource: Using the navigator Object to Detect Java
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use