Why is it that whenever I do :-
JSON.parse('"something"')
it just parses fine but when I do:-
var m = "something"; JSON.parse(m);
it gives me an error saying:-
Unexpected token s
You're asking it to parse the JSON text something (not "something"). That's invalid JSON, strings must be in double quotes.
something
"something"
If you want an equivalent to your first example:
var s = '"something"'; var result = JSON.parse(s);
1.4m articles
1.4m replys
5 comments
57.0k users