why the outputs are different
Because the inputs are different.
FIRST scenario
obj = {a:"asdf"};
var newObj = JSON.parse(JSON.stringify(obj));
Here the input parameter of JSON.parse is JSON.stringify(obj)and this is a string that reads {"a":"asdf"}.
SECOND scenario
var newObj = JSON.parse("{"a":"asdf"}");
Here the input parameter of JSON.parse is a string that reads { and the rest is broken code.
Confusion arises because the console debugger decides all strings should be shown on the console encapsulated with a ", but this is just a way for the console to tell you that this value is of type String. It does not check whether you have " inside and escape them.
The encapsulating " are not part of the string, only a way of telling it is a string.
If console.logging JSON.stringify(obj) gets you "{"a":"asdf"}" try doing alert instead, or document.write. These will not add extra " and you will see that the value of JSON.stringify(obj) is actually {"a":"asdf"}, not "{"a":"asdf"}".
<html><head></head><body>
<script>
function JSONparse(string) {
document.write(string);
alert(string);
console.log(string);
return JSON.parse(string);
}
var obj = {a:"asdf"};
result = JSONparse(JSON.stringify(obj));
</script>
</body></html>
"{"a":"asdf"}"this is not a properly formatted string. If you start a string with " then you end it with ". Which means, here the string is only "{" and the rest is broken code the browser doesn't know what to do with. As said in answers you can either use ' to encapsulate the whole string as'{"a":"asdf"}'or you escape the inner " as"{\"a\":\"asdf\"}"."{"a":"asdf"}"but it is actually returning a string that reads{"a":"asdf"}. The browser console decides to encapsulate this in a " because that is the default console behaviour with strings. So you will read"{"a":"asdf"}"but it is actually a type string with a value of{"a":"asdf"}.JSON.parse('{"a":"asdf"}'). Check my answer, I try to explain it there.