Question:

Which built-in JavaScript function is used to convert a value to an integer ?

Show Hint

Always include the radix parameter when calling parseInt() (like parseInt(value, 10)) to ensure your strings are parsed reliably using the base-10 numbering system across different browsers.
Updated On: Jun 29, 2026
  • parseFloat()
  • alert()
  • isNaN()
  • parseInt()
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation



Step 1: Explaining Built-in JavaScript Utility Functions:

JavaScript has global built-in functions to convert data types and check values:

Step 2: Evaluating the Options:


(A) parseFloat(): Parses a string argument and returns a floating-point (decimal) number. For example, parseFloat("3.14") returns 3.14.
(B) alert(): Displays a pop-up alert dialog box on the screen with a specified message.
(C) isNaN(): Determines whether a passed value is NaN (Not-a-Number).
(D) parseInt(): Parses a string argument and extracts an integer value. For example, parseInt("3.14") returns the integer 3. It also accepts a second argument (radix) to specify the mathematical base (e.g., base 10, binary base 2, hexadecimal base 16). Thus, parseInt() (D) is the correct built-in function to convert values to integers.
Was this answer helpful?
0
0