Uncaught ReferenceError: uneval is not defined
It works well with Firefox, but not work with Google Chrome.
I try:
var getSaved = [['ABC', 'http://...'], ['DEF', 'http://...'], ['...etc...']];
var get_saved_items = eval(getSaved);
var name = [], url = [];
for (var i = 0; i < get_saved_items.length; i++) {
name[i].push(get_saved_items[i][0]);
url[i].push(get_saved_items[i][1]);
};
window.localStorage.setItem('saved_name', uneval(name));
window.localStorage.setItem('saved_links', uneval(url));
it returns: Uncaught ReferenceError: uneval is not defined
What’s the problem?
Using ‘eval’ is not recommended because of different reasons (you can google it).
unevalwill not work in other browsers.For your requirement you can use a JSON parser. Widely used one is Crockford’s JSON parser.
https://github.com/douglascrockford/JSON-js/blob/master/json2.js
demo : http://jsfiddle.net/xVvBp/