1

It is said that null, in JavaScript, is a primary type. However, when I use the operator typeof on null, it returns "Object".

What is the underlying procedure that made typeof to return "Object" instead of "Primitive" or "null"?

0

1 Answer 1

1

Type of null is object.

you can check type of any variable with typeof keyword. for example

typeof null 

check the link below for more details.

Sign up to request clarification or add additional context in comments.

8 Comments

if null is an object, why can't I add a property to it?
because By definition neither the null value nor the undefined value have any properties, nor can any properties be added to them.
@DatV. you need to accept the answer if I helped.
According to the spec, this is incorrect. null is an instance of the type "Null". The unexpected typeof null value was chosen for enhanced compatibility with Java.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.