Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Objects
Array Object
Pop
Push
Shift
METHOD: Array::unshift
Array.
unshift
(element1,..., elementN)
The
unshift
method adds one or more elements to the beginning of an array and returns the new length. The following code first creates an array called 'trees' and then uses the
unshift
method to add two new elements to the beginning of it, returning the new length of the array. Finally, the third line of code displays all the elements of the altered array:
Code:
trees = ["beech", "maple", "sycamore"]
document.write(trees.unshift("oak", "ash"))
document.write("<BR>" + trees)
Output:
5
oak,ash,beech,maple,sycamore
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information