Friday, August 29, 2025
HomeLanguagesJavascriptTypeScript Number valueOf() Method

TypeScript Number valueOf() Method

The valueOf() method in TypeScript is used to return the primitive value of the specified number object.
Syntax:

number.valueOf()

Parameter values: This method does not accept any parameter.

Return Value: The valueOf() method in TypeScript returns the primitive value of the specified number object.

Below examples illustrates the working of valueOf() function in TypeScript:
Example 1:

javascript




//valueOf()
var num3 = new Number(30);
console.log(num3.valueOf());


Output: 

30

Example 2:

javascript




// valueOf() method
let num4 = new Number(563);
console.log("Number Method: tovalueOf()");
console.log(typeof num4 )
console.log(num4 )
console.log(num4 .valueOf())


Output: 

Number Method: tovalueOf()
number
[Number: 563]
563
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11790 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11838 POSTS0 COMMENTS
Shaida Kate Naidoo
6731 POSTS0 COMMENTS
Ted Musemwa
7011 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6701 POSTS0 COMMENTS