JavaScript Number valueOf() method

Definition and usage

valueOf() The method returns the original value of the number.

Example

Get the original value of the number:

let num = 15;
let n = num.valueOf();

Try it yourself

Syntax

number.valueOf()

parameter

no parameters.

return value

type Description
number original value of the number.

Technical details

return value

number original value. There is almost no need to explicitly call this method.

thrown

Exception Description
TypeError An exception is thrown if the object called by the method is not a Number.

browser support

valueOf() Er ECMAScript1 (ES1) egenskaber.

Alle browsere understøtter fuldt ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support