JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Javascript unshift() Method - Array Function


Tutorials Javascript

Topic

How to add new elements into the Beginning of the array and shift the index of the subsequent element to the higher value ?
What is the use of unshift() function in javascript?



Explanation
Method: unshift() :
        This function add new elements into the Beginning of the array and shift the index of the subsequent elements to the higher value. It also returns the new length of the array.

Syntax:
array1.unshift();

Example Code:
<script type="text/javascript">
var a["a","b","c","d"]
var ele = stack.unshift(3);
document.write(ele);
</script>


Result:


In the above example, this method add new element to the beginning of the array and has displayed the result as"5".




A Note
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

Other Links

web hosting