2

MDN says there are nine data types in latest JS spec. I wondering if these are the only nine data types that the spec allows programmers to use.

Just to clarify, I think programmer-defined functions/constructors internally using prototypical inheritance are still Objects, so do not qualify as new data types.

7
  • What do you have in mind? What's the rest of the question? Commented Apr 15, 2021 at 7:59
  • 2
    No, you cannot make your own double or long or anything else. The data types you have are all there is. The only way to get new ones is to 1. write a proposal for a new one and get it approved 2. write your own interpreter and engine that does whatever you want. Commented Apr 15, 2021 at 7:59
  • Your question is not clear: 1.- "I wondering if these are the only nine data types that the spec allows programmers to use." You mean there could be more? What is your suggestion? 2.- Functions are still objects, so should not be considered as a different type. Then we should have 8 types instead of 9. What is the point you would like to make in your question? Commented Apr 15, 2021 at 8:03
  • @JeremyThille There is no "rest" of my question. I was interested in JavaScript's type system, and just wondered if it is possible to create a new data type and then values of that type. Commented Apr 15, 2021 at 8:12
  • @rustyBucketBay I agree the referenced MDN page is a bit messy, and that Function can be categorized as special objects with a [[call]] internal property. I was just curious if it is possible to create new data types. Commented Apr 15, 2021 at 8:16

1 Answer 1

1

There is no facility that allows defining custom core data types in JavaScript. You can only use them and objects to construct what you want.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.