How to Work With Numbers When Programming in Javascript


show more All JavaScript numbers are floating-point numbers. That means they're easy to write. But there are some tricks to working with them. Learn how to combine numbers with strings, use the built-in number function and math object, and other tips to working with numbers in JavaScript. show less
please wait ...

Working with numbers

Working with numbers comes easily in JavaScript. We've already done this. We can create variables and put numbers in them. And like any language, we have the notion of numeric variables, we have the notion of numeric literals. In this case, just the value 200 written in your code is a numeric literal. But if you're coming from another programming language, you're likely to be thinking, "What kind of number is this. What kind of variable is this? Is this an integer, is it a floating- point number, what kind of number is it? We don't have to ask those questions in JavaScript because internally all JavaScript numbers are 64- bit floating-point numbers.

That's how they're stored under the hood. So you don't concern yourself whether it's an integer or a small integer or a large integer and so on. Now if you're familiar with floating- point arithmetic, you'll know that you can have issues with that. In practice, that doesn't tend to be a problem in Ja...

Working with numbers
Video duration: 6m 13s 5h 31m Beginner

Viewers:

All JavaScript numbers are floating-point numbers. That means they're easy to write. But there are some tricks to working with them. Learn how to combine numbers with strings, use the built-in number function and math object, and other tips to working with numbers in JavaScript.

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...