What is the use of valueOf() method in JavaScript?

What is the use of valueOf() method in JavaScript?

JavaScript, JavaScript Method, Method, valueOf()

41 | 0 | 0

The valueOf() method returns a number as a number.

let a = 456;

console.log(a.valueOf());               // 456

console.log((456).valueOf());           // 456

console.log((426 + 30).valueOf());      // 456

 

Comments (0)

🤔

No comments yet, be the first to help

Welcome to CodePits.

CodePits provide a collection of tutorials about many programming languages like PHP, Laravel Framework, Codeigniter Framework, Mysql Database, Bootstrap Front-end Framework, Jquery, Node JS, Ajax Example, APIs, CURL Example, Composer Packages Example, AngularJS, Ionic Framework, etc. 🙌

Other Posts

Categories

Tags

Comment