0

At most places on Web, data types in JavaScript are mentioned as -

  • Boolean
  • Null
  • Undefined
  • Number
  • String
  • Symbol
  • Object

I have a query about data type of a function -

The typeof operator for a function declaration or definition returns "function". Then how come "Function" is not listed as a data type? Also, aren't functions Objects in JavaScript? Then how come typeof of function declaration or definition returns "function" and not "Object"?

Abhinandan Khilari
  • 947
  • 3
  • 11
  • 26
  • Edited the question now and removed the part which seem duplicate from the question. Please remove the duplicate marker on the question. – Abhinandan Khilari Jul 27 '18 at 07:07
  • The `typeof` operator returns "function" for function objects because the spec says so. See [MDN JavaScript Reference - `typeof` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof). See also [MDN JavaScript Reference - Data Types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types). – georgeawg Jul 30 '18 at 21:50

0 Answers0