JS Startup

Challenges, Tips & Tricks & Tutorials

JavaScript Quiz – does class typeof operator give class

JavaScript Quiz – does class typeof operator give class

JavaScript class typeof

In javascript, typeof operator is used to detect the data type of unevaluated operand and return values is in string. There are many data type like string, number, boolean etc. In the same way class also return it’s data type.

Basic Syntax of typeof

typeof operand

Example of typeof

typeof "JS Startup" // String
typeof(100) // Number

For more detail about the javascript typeof click here.

JavaScript Question

In this javascript quiz, find out does class typeof operator give class as data type because typeof return string value with data type.

First we declare a class with name students and students class does not have any method and variable.

class students{


In the second step, we create a variable student using let keyword and assign students class with new keyword.

let student = new students();

Now, we are checking the data type of student variable using console log.

console.log(typeof student);

JavaScript Quiz Test

class students{


let student = new students();

console.log(typeof student); // output => ?

Any idea what should be the output of the above statement ?

Answer – object”

Click To Run Code


Now, you know the answer is “object” but why does it should be class data type.

InShort, a student is not a class it’s an object of class students so a student is a type of an object when typeof check against student variable.

But even if you check directly the typeof students which is class. Then it not gives you a class data type but it give you a “function“.

At last, That’s why we get an answer “object“.

Let me know in the comment section, what you think about it.

I hope you understand the concept and logic behind it.

But wait, i have something more for you –

Check out our other javascript quiz – 

  1. JavaScript Quiz – what does the async array map function return
  2. JavaScript Quiz – can array really be access with an array
  3. JS Quiz – what really is the array index value
  4. JS Quiz – does object hasOwnProperty really return boolean


To participate in our javascript quiz or challenges, tutorial, tips & tricks make sure to join our jsstartup newsletter. So, you can able to participate in our daily challenges & learn the javascript concept.

And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page

If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
Share via
Copy link