Navigate back to the homepage

How to check value is number or not in javascript?

Infinitbility
JavaScript
November 2nd, 2021 · 1 min read
How to check value is number or not in javascript?

Hello Friends 👋,

Welcome To Infinitbility! ❤️

Javascript provides multiple ways to check value is a number or not isNaN(), and typeof methods are some of those.

Now, we are going to see how we can use the isNaN(), and typeof methods to check the given value is number.

Let’s start today’s tutorial How to check value is number or not in javascript?

Javascript isNaN() method

Javascript provides the isNaN() method to identify data is number or not just like is full form Not a number.

it will return true id provided value is not a number, else return false.

Let check isNaN() method.

1const value = 10
2
3// number
4isNaN(value) //false
5
6// object
7isNaN({}) //true
8
9// float
10isNaN(1.2) //false
11
12// string
13isNaN('infinitbility') //true

isNaN() method return false, if a value is a number.

output

isNan, Javascript, Example

Javascript typeof method

Javascript provides typeof operator to check the type of data, when we pass any number, float then typeof return number.

1const value = 2
2
3typeof value //'number'

Output

typeof, Javascript, Example

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo

Tutorials

Categories

More articles from Infinitbility

Guidebook The Javascript Monorepo

Guidebook The Javascript Monorepo

Example of Javascript Monorepo

November 1st, 2021 · 1 min read
How to replace all occurrences of a string in JavaScript?

How to replace all occurrences of a string in JavaScript?

Example of replace all occurrences of string in javascript, React, React Native, vue, node, deno, typescript and all javascript framework.

November 1st, 2021 · 1 min read
© 2020–2021 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]