# JavaScript Questions & Answers – Parsing Values using JavaScript – II

This set of JavaScript Multiple Choice Questions & Answers focuses on “Parsing Values using JavaScript – II”.

1. What is the purpose of the radix parameter in the parseInt() method?
a) Numeral system not to be used
b) Numeral system to be used
c) Conversion mode
d) Parsing mode

Explanation: function parseInt() method parses a string and returns an integer. The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.

2. What will be the radix value of the parseInt() method when the string begins with 0?
a) 6
b) 7
c) 8
d) 9

Explanation: If the string begins with 0x, then the radix value will be 16. If the string begins with “0”, the radix is 8 (octal). This feature is deprecated.

3. What is the purpose of the method JSON.parse()?
a) Parses a string to integer
b) Parses a string to JSON
c) Parses a string from JSON to JSON2
d) Parses integer to string

Explanation: The JSON.parse() method parses a string as JSON, optionally transforming the value produced by parsing. The function parseInt() method parses a string and returns an integer.

4. What is the return type of the method parseInt()?
a) String
b) Float
c) Integer
d) Date

Explanation: The function parseInt() method parses a string and returns an integer. The method parseInt() returns an integer.

5. What are the parameters of the method JSON.parse()?
a) text
b) reviver
c) both text and reviver
d) object

Explanation: The JSON.parse() method can optionally transform the result with a function. The parameters of the method JSON.parse() are :

• text : The string to parse as JSON.
• reviver : If a function, prescribes how the value originally produced by parsing is transformed, before being returned.

6. What will be the radix value of the parseInt() method when the string begins with any other value other than 0x and 0?
a) 8
b) 9
c) 10
d) 11

Explanation: The radix value will be 10 when the string of the method parseInt() begins with any other value other than 0x and 0. If the string begins with 0x, then the radix value will be 16.

7. 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

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.

8. Which of the following is a JavaScript Compressor?
a) Esprima
b) UgilifyJS
c) Acron
d) Compressify

Explanation: UgilifyJS is a JavaScript compressor/minifier written in JavaScript. It also contains tools that allow one to automate working with JavaScript code.

9. What is the purpose of the UgilifyJS?
a) Exposes a simple API
b) Minification
c) Both Exposes a simple API and Minification
d) Compilation

Explanation: UglifyJS is a JavaScript compressor/minifier written in JavaScript. UglifyJS2 is an excellent tool to help you minify your JavaScript! It’s a tried and tested tool, used by libraries such as jQuery.

10. Which of the following is the fastest JavaScript parser?
a) JSLint
b) Esprima
c) Acron
d) Traceur

Explanation: Acorn is a JavaScript parser written in JavaScript. : Acron is the fastest JavaScript parser written in JavaScript which takes only 96.9ms when compared to all the JavaScript parsers available. Acron is the fastest JavaScript parser written in JavaScript which takes only 96.9ms when compared to all the JavaScript parsers available.

Sanfoundry Global Education & Learning Series – Javascript Programming.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]