- Home /
Question by
amnakhan786 · Apr 15, 2012 at 03:27 AM ·
javascriptobjectarrays
how to save an array into an object
hi, 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
Comment
Answer by DaveA · Apr 15, 2012 at 04:18 AM
Very good discussion here: http://unity3d.com/support/documentation/ScriptReference/Array.html