how to save an array into an object

i want to save an array in an object in runtime through a loop:
for example
i take an input in an array inp=[2,7,20,15,19]
and i want to save it in an obj={0:2,1:7,2:20,3:15,4:19} but at run time such that
i have a
for(i=0;i<inp.length;i++) { save each element of array into the respective object element } the problem is that i have to save arrays of different lengths that i am taking as input from user.
i searched alot for a clue to get started but i could not find anything.

thanks in advance

Very good discussion here: