christys Posted July 26, 2014 Share Posted July 26, 2014 (edited) Hi, I trying to write a code for iterating through the array. Array size will be dynamic, that means we don't know how many elements are there internally. So how can I create an array without size. And my array will be a string. var membernames=new Array(); Can I initialize this way? I want to loop through a set of elements whose size is unknown and retrieve all those details into a variable. How can I do this? Please let me know.. Thanks Edited July 26, 2014 by christys Link to comment Share on other sites More sharing options...
niche Posted July 26, 2014 Share Posted July 26, 2014 http://www.w3schools.com/php/php_looping_for.asp Link to comment Share on other sites More sharing options...
thescientist Posted July 26, 2014 Share Posted July 26, 2014 http://www.w3schools.com/php/php_looping_for.asp that's PHP. Hi, I trying to write a code for iterating through the array. Array size will be dynamic, that means we don't know how many elements are there internally. So how can I create an array without size. And my array will be a string. var membernames=new Array(); Can I initialize this way? I want to loop through a set of elements whose size is unknown and retrieve all those details into a variable. How can I do this? Please let me know.. Thanks I'm not sure what you're asking. Do you want to know how to iterate through an unspecified array size at runtime? If so, you can use push to add to an array, and use the length property to use as the ending conditional for a for loop. You can find this info in the Array references sections http://www.w3schools.com/js/js_arrays.asp http://www.w3schools.com/jsref/jsref_obj_array.asp Link to comment Share on other sites More sharing options...
niche Posted July 26, 2014 Share Posted July 26, 2014 dooh! Link to comment Share on other sites More sharing options...
davej Posted July 27, 2014 Share Posted July 27, 2014 I want to loop through a set of elements whose size is unknown and retrieve all those details into a variable. Posting code or pseudocode would be better than the vague description you are providing. Have you gone through the tutorial? http://www.w3schools.com/js/default.asp Link to comment Share on other sites More sharing options...
Ingolme Posted July 28, 2014 Share Posted July 28, 2014 All arrays in Javascript have a length property which indicates how many elements they contain. If it doesn't have a length property then it's not an array. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now