Q
Which method can convert a number to a different base (e.g., hexadecimal)?

Answer & Solution

Answer: Option A
Solution:
The toString() method can convert a number to a different base. For example, (255).toString(16) returns 'ff'.
Related Questions on Average

Which method would you use to check if a value is a finite number?

A). isNaN()

B). isFinite()

C). Number()

D). toFixed()

What is the output of (255).toString(2)?

A). 255

B). 11111111

C). ff

D). 10

Which method returns the primitive value of a Number object?

A). toString()

B). valueOf()

C). toFixed()

D). parseFloat()

What is the result of parseInt('0xF', 16)?

A). 15

B). 0

C). NaN

D). 16

Which method converts a number to a string?

A). toFixed()

B). toString()

C). valueOf()

D). parseFloat()

What does isFinite(123) return?

A). 1

B). 0

C). NaN

D). undefined

Which method converts a string to a floating point number?

A). parseFloat()

B). toFixed()

C). toPrecision()

D). Number()

What does toPrecision(3) do?

A). Formats a number to 3 decimal places

B). Returns a number in exponential notation

C). Returns a string with a number written with a specified length

D). Converts a number to a string

What does Number('123abc') return?

A). 123

B). NaN

C). 123abc

D). undefined

What does Number('123') return?

A). 123

B). 123

C). NaN

D). 23