uzay95
uzay95

Reputation: 16642

JSON is no defined

in the json.js file i am getting an error on 199th line

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

Why is this happining?

Upvotes: 0

Views: 212

Answers (1)

Gumbo
Gumbo

Reputation: 655795

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 : {};

Upvotes: 1

Related Questions