Typeof in Javascript

JAVASCRIPT TYPEOF

 

The JavaScript typeof is an operator to recognize the type of its operator and returns the value as a string format

 

The Operand could be any Variable, Object, and Function, its mostly like use to know what type of data type action performing by the operand.

 

Let's explain with the example to deeply understand where, how, and when to use it.

 

Example 1:  How to use typeof in JavaScript.

console.log(typeof 'gomehere');

 

And now what you are expecting in Answer, what its returns, let see in below in the output section.

 

Output

String

So, now the question is? why its returns string? Hope! you know how it happened, because of type of always returns string form of the operand data type.

Let's take more typeof examples to understand.
 

 

Example 2 :

console.log(typeof90 ==='number');
console.log(typeof2.16 ==='number');
console.log(typeof(69) ==='number');   
  

In the above, we have taken three types of pattern and comparing with the number and let's see what happen in the output section.

Output

True
True
True

 

Yeah!! finally, We got true in all patterns because of javascript typeof returns numbers, Thus returns true for all.

 

 

 



About author

Author:- Mukesh Pant

Mukesh Pant

Founder of GOMEHERE and exploring new ideas in multiple areas like technology, programming, travel, sport, utility, and many more for the audience to solve their problems. Also, keep in touch by email mrpant90@gmail.com



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Comments

Scroll to Top