ab.c.title = {};
ab.c.title2 = {};
var searchstring = 'ab.c';
$.each(searchstring, function(x){
});
I have a string (var = searchstring) which will be used to build the string for the object i want to iterate through in $.each
if i type the object into the 'each' it works.
e.g
$.each(ab.c, function(x){ };
However if i declare as a string beforehand, this does not work:
var searchstring = 'ab.c';
$.each(searchstring, function(x){};
Is there a way to get around this?
[searchstring]. Try onceeval? (Yes, it's evil, slow and wrong, but it would work)searchstringbe "c", then:ab[searchstring]. Similar approaches will work for any similar promotion (i.e. putabas a property if needed), as long as there is a "common root" variable - in this case the object graph in question starts atab. More complex cases, i.e. given: x, how to resolve x.a.b from "a.b" are already answered on SO.