Classification cats' easy but Clasifacaiton JavaScrypt committeee members diff9kult becuase they arent cats. Meouzer
Mouser knows what he is talking about. JavaScript messed up type information because there isn't a single cat on the JavaScript committee. The native type was great for typing in ECMA-2009 but for ECMA-20015 they threw it all away for nothing because they don't have cats who would be curious enough to check things out. So coding the type() function in Data Typing in JavaScript isn't as Simple as you Think was possible only by mere luck and the JavaScript prowess of the cats of the Meouzer consortium.
The predecessors of dtype() are type() and usertype(). userType() like type() should be useful to the programmer because it provides basic data typing infrastructure that JavaScript itself lacks. The code for userType() is expanded to obtain the dtype() typing function that types in great detail. However, the reader will have no use for dtype() most likely.
The dtype() function has two important roles. It provides the headers for the stringify() function so that deserialization can take place. It also detects objects that are not suitable for serialization.
dtype(x) | The most specific thing to be said | Example value of x |
"Window" | x is the window | window |
"HTMLDocument" | x is the document | window.document |
"Boolean[Prototype]" | x is the Boolean prototype | Boolean.prototype |
"Boolean" | x is a Boolean class instance | new Boolean(true) |
"Boolean[Object]" | x is a Boolean instance of degree 1. However type(x) is "Object" because x is not a Boolean class instance. | Object.create(Boolean.Prototype) |
"Boolean[Object(2)]" | x is a Boolean instance of degree 2. However type(x) is "Object" because x is not a Boolean class instance. | Object.create(new Boolean(true)) |
"Boolean[Object(2)]" | x is a Boolean instance of degree 2. However type(x) is "Object" because x is not a Boolean class instance. | Object.create(Object.create(Boolean.prototype)) |
"Function" | x is a function | Boolean |
"Function[Object(2)]" | x is a Function instance of degree 2. However type(x) is "Object" because x is not a Function class instance. | Object.create(Boolean) |
"NullObject" | x is a null object, 1 degree from null | Object.create(null) |
"NullObject(2)" | x is a null object, 2 degrees from null | Object.create(Object.create(null)) |
"Object" | x is an object, 1 degree from Object.prototype | {a:1} |
"Object(2)" | x is an object, 2 degrees from Object.prototype | Object.create({a:1}) |
"foo" | x is an instace of the proper foo class one degree away from foo.prototype, and x itself is not a proper prototype. | new foo(...) |
"foo[Object(4)]" | x is an instace of the proper foo class four degrees away from foo.prototype, and x is not a proper prototype. | Use Object.create() on new foo() three times |
Full code is at typing.js