Selecting last item in array javascript -


this question has answer here:

so have array , user can add input html tag:

var example=["a","b"]; var command=document.getelementbyid("id"); 

so idk how long array when execute next step,which selecting last item in array , register in object

example.split(",") someobject[//how chose last item?] 

you can select last item in javascript array this

arr = example.split(","); lastarr = arr[arr.length - 1]; 

Comments