Numbers - methods Flashcards

1
Q

toFixed(n):

A

let num = 123.456;
console.log(num.toFixed(2)); // outputs “123.46”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

toString(radix):

A

let num = 10;
console.log(num.toString(2)); // outputs “1010”

toString(radix): This method returns a string representation of a number in the specified radix (base). The radix argument is an optional parameter and should be between 2 and 36. If no radix is specified, the method returns a string representation of the number in base 10.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

valueOf():

A

let num = 123.456;
console.log(num.valueOf()); // outputs 123.456

How well did you know this?
1
Not at all
2
3
4
5
Perfectly