Array - splice : Array : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Array »

 

Array - splice




<html>
<body>

<script type="text/javascript">
myCars=["BMW","Volvo","Xiali","Jili"]

document.write("myCars: " + myCars)
document.write("<br><br>")

removed=myCars.splice(2,0,"Volkswagen")
document.write("After adding 1: " + myCars)
document.write("<br><br>")

removed=myCars.splice(3,1)
document.write("After removing 1: " + myCars)
document.write("<br><br>")

removed=myCars.splice(2,1,"Seat")
document.write("After replacing 1: " + myCars)
document.write("<br><br>")

removed=myCars.splice(0,2,"Peugeot","Honda","Toyota")
document.write("After replacing 2 and adding 1: " + myCars)
</script>

</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Array