#javaScript #data-types
Hello there. My question is regarding the data types in “introduction to javaScript” section of the course.
In the context it is mentioned that, there are seven fundamental data types. However on MDN it, if I got it right, everything is classified under object category. Is it true that in javaScript similar to Java everything is an object.

On the other hand in this code also the typeof both numbers and a Number object are the same.

console.log(typeof(123) === typeof(Number(123)));

Here’s the link to the MDN’s documentation, under which everything is classified as objects.

simialrly to Java, in Javascript, there are some primitive types and everything else is an object.

123 is a number (which is a primitive type, not an object, I think),
(but methods for Number objects will work on 123).

If you wanted to create a number object instead of a number, You would do new Number(123)

console.log(typeof(123)); console.log(typeof(Number(123))); console.log(typeof(new Number(123)));
1 Like