Ask a Question    Search Answers  

Category
Computers >> Programming Concepts >> Java

Question
How to shift and unshift using JavaScript?  (1 answers) Posted by: nvreddy   Ask a Friend

Answers
1.

<script type="text/javascript">
var numbers = ["one", "two", "three", "four"];
numbers.unshift("zero");
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
</script>
This produces
zero one two
shift, unshift, push, and pop may be used on the same array. Queues are easily implemented using combinations.
    Answered by: venkatreddy04


    Add an Answer to this Question
    Add a New Question
    Notify updates to this question
    Mail to a Friend
Rate this answer:       Exact       Correct       somewhat correct       wrong       spam

User comments


  What environment variables do I need to set on my machine in order to be able to run Java programs?
  Can a public class MyClass be defined in a source file named YourClass.java? ?
  What will be the default values of all the elements of an array defined as an instance variable?
  What is the difference between static and non-static variables?
  How does Java handle integer overflows and underflows?
  What is synchronization and why is it important?
  How do I dynamically disable/ enable form elements using JavaScript?
  How do I manipulate radio and check boxes in JavaScript?
  How do I validating forms using JavaScript?
  How do I access forms using JavaScript?
  How do I add a link to print only one part of a web page?
  How do I add a print button to a web page?
  Which features of the browser window can I control from JavaScript, and when?
  How can I delete a cookie with JSP?
Add New Question
Glossary
Add Glossary
 
Copyright © 2009-10 Krify Software Technologies Pvt Ltd. All rights reserved.