What kind of an exception will be thrown if the string to parse is not valid JSON?

Phương Linh

New member
What kind of an exception will be thrown if the string to parse is not valid JSON?
A. SyntaxError
B. ArrayOutOfBoundException
C. Both SyntaxError and ArrayOutOfBoundException
D. Compilation error
 
Answer: a
Explanation: The JSON.parse() method parses a string and returns a JavaScript object. The method JSON.parse()throws a SyntaxError exception if the string to parse is not valid JSON.
 

Tìm kiếm

Back
Top