In Javascript: Which of the following is true about the parseInt() function? a.
ID: 3688581 • Letter: I
Question
In Javascript:
Which of the following is true about the parseInt() function?
a.
parseInt() is a user-defined function used to convert string data to an integer.
b.
parseInt() is a user-defined function used to convert an integer to string data.
c.
parseInt() is a built-in function used to convert string data to an integer.
d.
parseInt() is a built-in function used to convert an ingeger to string data.
a.
parseInt() is a user-defined function used to convert string data to an integer.
b.
parseInt() is a user-defined function used to convert an integer to string data.
c.
parseInt() is a built-in function used to convert string data to an integer.
d.
parseInt() is a built-in function used to convert an ingeger to string data.
Explanation / Answer
option c
explnation:
The parseInt() function 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.
If the radix parameter is omitted, JavaScript assumes the following:
Note: Only the first number in the string is returned!
Note: Leading and trailing spaces are allowed.
Note: If the first character cannot be converted to a number, parseInt() returns NaN.
Note: Older browsers will result parseInt("010") as 8, because older versions of ECMAScript, (older than ECMAScript 5, uses the octal radix (8) as default when the string begins with "0". As of ECMAScript 5, the default is the decimal radix (10).
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.