From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Learn about JavaScript’s Number type

Learn about JavaScript’s Number type

- The first basic data type in JavaScript is numbers. Now, depending on what language you're coming to JavaScript from, you may find that JavaScript's treatment of numbers is much simpler than you're used to. In JavaScript, there are no separate types for integers and floating point numbers, although there is a separate data type for very big numbers, which we'll see in a bit. So if we have two variables, X equals 5 and pi equals 3.1415, these are both considered by JavaScript to be the same exact data type, a number. And negative numbers are allowed as well as one might expect. So using decimal notation is definitely the most common way to define numbers in JavaScript, and personally, I find that this constitutes 99% of all my use cases, but there are actually several additional ways that we can define numbers in JavaScript. For example, we can define hexadecimal numbers by putting 0x at the beginning of a number. And in more recent versions of JavaScript, that is since ES6, we're…

Contents