Navigate back to the homepage

how to check data type in react native?

Infinitbility
React Native
September 8th, 2022 · 1 min read
how to check data type in react native?

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To check data type in react native, use typeof keyword it will return type of data just we have to use this keyword before variable or data.

Let’s see short example to use typeof to get data type of value.

1typeof "Hello";

Today, I’m going to show you How do I check data type in react native, as above mentioned, I’m going to use the above-mentioned typeof method.

Let’s start today’s tutorial how do you check data type in react native?

React native check data type example using typeof

Here, we will take example of string, number, boolean, object and undefined datatype.

1import React, { useState, useEffect } from "react";
2import { Text, View } from 'react-native';
3export default function App() {
4
5 useEffect(() => {
6 console.log(typeof "Infinitbility");
7 console.log(typeof 2);
8 console.log(typeof true);
9 console.log(typeof {id: 1});
10 console.log(typeof undefined)
11 }, []);
12
13 return (
14 <View>
15 <Text>{typeof "Infinitbility"}</Text>
16 <Text>{typeof 2}</Text>
17 <Text>{typeof true}</Text>
18 <Text>{typeof {id: 1}}</Text>
19 <Text>{typeof undefined}</Text>
20 </View>
21 );
22}

Output

I hope it helps you, All the best 👍.

Follow me on Twitter

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 Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to check null value in react native?

how to check null value in react native?

An example of check null value in react native with the step-by-step guide.

September 8th, 2022 · 1 min read
how to check blank space in typescript?

how to check blank space in typescript?

An example of check blank space in typeScript with the step-by-step guide.

September 7th, 2022 · 1 min read
© 2020–2022 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]