In every language, we need to validate data before modifying or displaying it.
So, here in the case of javascript also we almost regularly use these functions and we maintain all these in single util class to reuse quickly.
No further theory let’s jump into stuff.
Basically,
Use the above reference and write isFunctions
now:
isNumber
(+/-)Infinity is of type number in javascript as if you want to avoid then you can update logic as:
isBoolean
isString
isObject
isArray
isFunction
isInteger
We can use Number.isInteger(value)
Yes. There are some exceptions based on where do we use these functions.
Please do suggest if I miss any mandatory validations in the above isFunctions.
Hope these help to a little extent instead of going over lengthy explanations around the globe 😝.
Thank you! Happy Reading :)
💎 Love to see your response
- Like - You reached here means. I think, I deserve a like.
- Comment - We can learn together.
- Share - Makes others also find this resource useful.
- Subscribe / Follow - to stay up to date with my daily articles.
- Encourage me - You can buy me a Coffee
Let's discuss further.
- Just DM @urstrulyvishwak
-
Or mention
@urstrulyvishwak
Top comments (1)