check for a remainder when dividing by 1:

function isInt(n) {
   return n % 1 === 0;
}

If you don't know that the argument is a number you need two tests:

function isInt(n){
    return Number(n) === n && n % 1 === 0;
}

function isFloat(n){
    return Number(n) === n && n % 1 !== 0;
}

Update 2019 5 years after this answer was written, a solution was standardized in ECMA Script 2015. That solution is covered in this answer.

Answer from kennebec on Stack Overflow
🌐
SheCodes
shecodes.io › athena › 24061-what-is-a-float-in-javascript
[JavaScript] - What is a float in JavaScript? - SheCodes | SheCodes
Learn about the float data type in JavaScript and how it's used to represent numbers with a fractional part or very large/small numbers.
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard. This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-check-if-a-number-is-float-or-integer
JavaScript Program to Check if a Number is Float or Integer - GeeksforGeeks
July 23, 2025 - JS Tutorial · Web Tutorial · ... see how to check whether a number is a float or an integer in JavaScript. A float is a number with a decimal point, while an integer is a whole number or a natural number without having a decimal ...
🌐
Stack Abuse
stackabuse.com › bytes › check-if-a-number-is-a-float-or-integer-in-javascript
Check if a Number is a Float or Integer in JavaScript
September 10, 2023 - You may not have known this, but in JavaScript, all numbers are treated as floating-point numbers, regardless of whether they have decimal places or not. This is because JavaScript follows the IEEE 754 standard for Binary Floating-Point Arithmetic.
🌐
DEV Community
dev.to › uzairsamad › how-to-check-if-number-is-float-in-js-h98
How to check if Number is Float in JS - DEV Community
September 17, 2020 - Usually we check types in javascript by using typeOf method but javascript doesn't support float type...
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-check-if-value-is-float
Check if a value is a Float or an Integer in JavaScript | bobbyhadz
If the provided value is of type number, is not NaN and is not an integer, then the value is a floating-point number.
🌐
Programiz
programiz.com › javascript › examples › float-or-integer
JavaScript Program to Check if a Number is Float or Integer
// program to check if a number is a float or integer value function checkNumber(x) { // check if the passed value is a number if(typeof x == 'number' && !isNaN(x)){ // check if it is integer if (Number.isInteger(x)) { console.log(`${x} is integer.`); } else { console.log(`${x} is a float value.`); } } else { console.log(`${x} is not a number`); } } checkNumber('hello'); checkNumber(44); checkNumber(3.4); checkNumber(-3.4); checkNumber(NaN);
🌐
W3Schools
w3schools.com › jsref › jsref_parsefloat.asp
JavaScript parseFloat() Method
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion ... parseFloat(10); parseFloat("10"); parseFloat("10.33"); parseFloat("34 45 66"); parseFloat("He was 40"); Try it Yourself » · More examples below. ... The parseFloat() method parses a value as a string and returns the first number. If the first character cannot be converted, NaN is returned.
🌐
Altcademy
altcademy.com › blog › what-is-float-in-javascript
What is float in JavaScript - Altcademy.com
September 11, 2023 - In JavaScript, a float (more formally known as a floating-point number) is a type of data that allows you to store decimal numbers. This is in contrast to integers, which can only store whole numbers.
🌐
Reddit
reddit.com › r/javascript › [askjs] its about time javascript should get a "integer" and "float" data type.
r/javascript on Reddit: [AskJS] Its about time javascript should get a "integer" and "float" data type.
August 10, 2022 -

After all the improvements/features and fixes which were made to javascript (or precisely ECMAScript) since ES6 (ES2015) till now (ES2022), isn't it about time to fix the ultimate pending weakness i.e. having an Integer and a Float type as well (just like "var" keyword was/is there but they added "let" and "const" as a better semantics and good practice) and not just mashup everything in Number.

Heck, we even got a big int to represent big integers (no floats allowed) but we still don't have Integer's and Floats which are SUPER useful in almost every scenario.

So, why is it still not added and not planned as well? Those are VERY important data types and MOST languages HAVE those data types as they are NEEDED, why is it not planned for ECMAScript? Is it planned? Do you want to see this added?

🌐
TutorialsPoint
tutorialspoint.com › article › how-do-i-check-that-a-number-is-float-or-integer-javascript
How do I check that a number is float or integer - JavaScript?
October 3, 2020 - For floats, value % 1 returns the decimal part: function checkNumberIfFloat(value) { return Number(value) === value && value % 1 !== 0; } var value1 = 10; var value2 = 10.15; if (checkNumberIfFloat(value1)) { console.log("The value is float=" + value1); } else { console.log("The value is not float=" + value1); } if (checkNumberIfFloat(value2)) { console.log("The value is float=" + value2); } else { console.log("The value is not float=" + value2); }
🌐
Altcademy
altcademy.com › blog › what-is-a-float-in-javascript
What is a float in JavaScript - Altcademy.com
September 14, 2023 - Floats are an important aspect of JavaScript that you will inevitably cross paths with as you delve deeper into your programming journey. So, what exactly are they? Well, in the simplest terms, a float (short for 'floating point number') is ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number
Number - JavaScript - MDN Web Docs - Mozilla
js · 255; // two-hundred and ... (binary notation) 255 === 0.255e3; // true (decimal exponential notation) A number literal like 37 in JavaScript code is a floating-point value, not an integer....
🌐
Codecademy
codecademy.com › docs › javascript › number methods › .parsefloat()
JavaScript | Number Methods | .parseFloat() | Codecademy
May 31, 2024 - In JavaScript, the .parseFloat() method parses a given string and returns the first floating-point number found in the string. Parsing stops when it encounters a character that is not part of a valid number. If the input string cannot be converted to a valid floating-point number, the method returns NaN.
🌐
Vultr Docs
docs.vultr.com › javascript › examples › check-if-a-number-is-float-or-integer
JavaScript Program to Check if a Number is Float or Integer | Vultr Docs
November 7, 2024 - This function checks if a number is an integer by comparing it to its floored version. If they are the same, the number is an integer; otherwise, it is a float.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › float
float CSS property - CSS | MDN
As float implies the use of the block layout, it modifies the computed value of the display values, in some cases: Note: When accessing a CSS property in JavaScript through the HTMLElement.style object, single-word property names are used as is. Although float is a reserved keyword in JavaScript, ...
🌐
The Floating-Point Guide
floating-point-gui.de › languages › javascript
The Floating-Point Guide - Floating-point cheat sheet for JavaScript
To force a variable to floating-point, use the global parseFloat() function. ... The oldest decimal type for JavaScript seems to be a port of Java’s BigDecimal class, which also supports rounding modes: var a = new BigDecimal("0.01"); var b = new BigDecimal("0.02"); var c = a.add(b); // 0.03 var d = c.setScale(1, BigDecimal.prototype.ROUND_HALF_UP); There is also bignumber.js, which is smaller and faster: