开发者

JSON is no defined

开发者 https://www.devze.com 2023-01-19 19:39 出处:网络
in the json.js f开发者_C百科ile i am getting an error on 199th line 199: JSON = JSON || {}; error is, JSON is not defined

in the json.js f开发者_C百科ile i am getting an error on 199th line

199: JSON = JSON || {}; error is, JSON is not defined

Why is this happining?


In fact, reading the value of an undefined variable throws a ReferenceError (see GetValue(V) in ECMAScript). So you should use typeof before accessing it:

JSON = typeof JSON !== "undefined" ? JSON : {};
0

精彩评论

暂无评论...
验证码 换一张
取 消