0

Mysql has the different integer datatype like, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT. Is there any way to detect the number is falling under which data type in JavaScript?

mkHun
  • 5,891
  • 8
  • 38
  • 85

2 Answers2

1

JavaScript only has one datatype for numbers: Number

(BigInt is proposed for a future version of JS).

So, all else being equal: You can't.

Your database API might provide a mechanism that would expose that information, but it would depend on the database API you were using.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks @Quentin. Actually I am creating the YAML file by reading the CSV input (using node js). So in the `type` attribute I have to mention the number data type. – mkHun Sep 06 '19 at 15:03
0

In JavaScript, there is no such categorization as such int or float, there is only number, more details about datatypes in JavaScript here.

Further if you need to check weather the value is int of float, you can the answer in following link here

Nikhil Kinkar
  • 761
  • 8
  • 31