Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,
I have declared one array at the top of the script tag like this
var qArr = new Array();

and by using for loop I am adding elements to that by this code
qArr.push(element);

I want to get single element from this, for that am using this line of code
var item = qArr[index];

But, Unfortunately it is returning all the elements from the array. Can any one please guide me that where am doing wrong?

thanks in advance
(Keerthi Kumar)
Posted
Comments
Mohibur Rashid 22-Apr-15 3:33am    
what for have to do to push an element?

1 solution

Instead of var qArr = new Array(); try var qArr = [];

There is a suggestion here[^] to avoid new array().
 
Share this answer
 
Comments
Keerthi Kumar(Andar) 22-Apr-15 1:02am    
no...still same
Abhinav S 22-Apr-15 1:15am    
What element are you pushing into the array? Is it an array too?
Keerthi Kumar(Andar) 22-Apr-15 1:19am    
var Questions="";
its a string, I am getting it from ajax call like this
Questions = $.parseJSON(data.d);
the Questions contains around 75 elements all these elements are stored in separate index because array length is 75 it is showing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900