1.

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 errorI got this question in exam.My question comes from Parsing Values using JavaScript topic in division Parsing, Benchmarking and Logging of JavaScript

Answer»

The correct answer is (a) SYNTAXERROR

The EXPLANATION is: 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.



Discussion

No Comment Found

Related InterviewSolutions