1
內容響應:{"body": "123", "timestamp": 1366853254, "html": "<div class=\"message\" id=\"m721cfd57-cf57-4fa9-b0a4-263151da4f7d\"><b>Scuk: <\/b>123<\/div>\n", "from": "Scuk", "id": "721cfd57-cf57-4fa9-b0a4-263151da4f7d"}
javascript - 爲什麼在評估對象時添加括號?
代碼:
console.log(eval('(' + response + ')'));
console.log(eval(response));
沒有錯誤在console.log(eval('(' + response + ')'));
報道而unexpected token
報道console.log(eval(response));
。有誰能告訴我爲什麼?
參見http://stackoverflow.com/questions/964397/why-does-javascripts-eval-need-parentheses-to-eval-json-data – potatosalad 2013-04-25 01:32:30
'的console.log(EVAL(響應+)) ;'裏面有''+'「,這是無效的。其餘的推理是在 – pickypg 2013-04-25 01:36:34
@pickypg以下對不起,這是一個錯字。 – CDT 2013-04-25 01:49:11