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?

2
  • i would just hard code it with greater than and less than Commented Sep 6, 2019 at 15:01
  • @RolandStarke — That could tell you the smallest DB datatype that would hold the number you had, but it wouldn't tell you the actual datatype. Commented Sep 6, 2019 at 15:02

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.