jQuery - Convert String to Javascript Array

I have a string like this:
var string = “[[1088163336,80],[1088154636,95],[1088150436,75]]”

I want to be able to run operations on this string such as string.length, string.each, etc. What do I need to do to convert this string object to an array object. Also note, that it is important to also preserve the string object during the process.

I have tried this, but it is giving me a syntax error:


var string = "[[1088163336,80],[1088154636,95],[1088150436,75]]"
var arrayLit = string;
if(eval(arrayLit).length > 1){
//Some Stuff
}

Thanks for any suggestions you may be able to offer.

It turns out the actual problem is illformated strings. I’m trying to create a regex to replace all characters in the string which are not: numeric, brackets, commas, or decimals.

This is what I have so far, but I don’t really know what I’m doing so any suggestions would be appreciated.

$jq(arrayLit).text.replace(/[^0-9]+/g,“”);

The JSON.parse() function that’s built in to many web browsers can help you there.


var array = JSON.parse('[[1088163336,80],[1088154636,95],[1088150436,75]]');