The Law of Absolutes: Using Math.abs, parseInt and parseFloat in JavaScript

added by JavaScript Kicks
8/30/2016 7:42:18 AM

753 Views

Dealing with numbers in JavaScript can be tricky. Received values don't always fall inside expected ranges; sometimes they're negative when you expect positive results. Sometimes they're not even cast as numbers. Dealing with these conditions, and converting strings into useful numerical results, often falls to s method - Math.abs() - and two functions: parseInt and parseFloat.


0 comments