Language Basics JavaScript DHTML




myCars=["BMW","Volvo","Xiali","Jili"]
document.write("myCars: " + myCars)
document.write("

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

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

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

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