Saturday, February 14, 2026
HomeLanguagesJavascriptJavaScript Number valueOf( ) Method

JavaScript Number valueOf( ) Method

JavaScript Number valueOf( ) method in JavaScript is used to return the primitive value of a number. This method is usually called internally by JavaScript and not explicitly in web code

Syntax:

number.valueOf()

Parameters: This method does not accept any parameter.

Return Value: The valueof() method in JavaScript returns a number representing the primitive value of the specified Number object. 

Below are examples of the Number valueOf( ) Method:

Example 1: In this example, the output comes out to be NaN as the value stored in the variable is NaN.

Javascript




let num=NaN;
console.log(num.valueOf());


Output:

NaN

Example 2: Passing a positive number as an argument in the valueOf() method. 

Javascript




let num=213;
console.log(num.valueOf());


Output:

 213

Example 3: Passing a negative number as an argument in the valueOf() method. 

Javascript




let num=-213;
console.log(num.valueOf());


Output:

-213

Example 4: Passing zero as an argument in the valueOf() method. 

Javascript




let num=0;
console.log(num.valueOf());


Output:

0

Example 5: Passing an equation(equating to infinite value) as an argument in the valueOf() method. 

Javascript




let num=0/0;
console.log(num.valueOf());


Output:

Nan

Supported Browsers:

  • Google
  • Edge
  • Firefox 
  • Apple Safari 
  • Opera

We have a complete list of Javascript Number Objects methods, to check those please go through this Javascript Number Complete reference article.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32503 POSTS0 COMMENTS
Milvus
129 POSTS0 COMMENTS
Nango Kala
6880 POSTS0 COMMENTS
Nicole Veronica
12002 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12093 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7253 POSTS0 COMMENTS
Thapelo Manthata
6963 POSTS0 COMMENTS
Umr Jansen
6954 POSTS0 COMMENTS