有時候我see在查看源代碼網頁(HTML查看源)驗證碼:JSON.stringify和「 u2028 u2029」檢查?
if (JSON.stringify(["\u2028\u2029"]) === '["\u2028\u2029"]') JSON.stringify = function (a) {
var b = /\u2028/g,
c = /\u2029/g;
return function (d, e, f) {
var g = a.call(this, d, e, f);
if (g) {
if (-1 < g.indexOf('\u2028')) g = g.replace(b, '\\u2028');
if (-1 < g.indexOf('\u2029')) g = g.replace(c, '\\u2029');
}
return g;
};
}(JSON.stringify);
- 什麼是
JSON.stringify(["\u2028\u2029"])
,它需要進行檢查的問題?
附加信息:
JSON.stringify(["\u2028\u2029"])
值爲"[" "]"
'["\u2028\u2029"]'
值也是"[" "]"
相關http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/和https://code.google.com/p/v8/issues/detail?id = 1907 – andyb