I have to use an array which is statically initialized as:
var my = new Array([30,10],[3,32])
I want to create this array dynamically but it seems it is not possible as it appends quotes and creates like this:
var my = new Array("[30,10],[3,32]")
function(data) {
var my = new Array(data);
}
I have tried replace, substring and any other possible way. Any body have any idea how to do this. This is very urgent.
eval?var my = new Array([30,10], [3,32]);is perfectly valid. It creates an array with two entries, each of which is, in turn, an array with two entries: jsbin.com/abemi4 It also works if the values come from other variables (e.g., rather than literals): jsbin.com/abemi4/2 In your quoted function, what woulddatacontain?"[30,10],[3,32]"come from? If you create it, why do you create a string? You can add elements to an array witharr.push().