The datatypes listed in MSDN for javascript are Number, String, Boolean, Object, Array, Null, Undefined. However, when you do typeof function
, its type is function.
Why is this the case, and what's the definition of datatype?
Functions are just Objects in JavaScript. But the difference lies in an internal property called [[Call]]
that differentiates them from normal Objects. When typeof
is used against an Object, and if it finds the [[Call]]
property, then it returns the String "function".
This behavior can be found in the ECMA Specification for typeof
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With