You've probably met typeof operator in the past. In the Accounting module of Watch and Code Premium, typeof is used to check if a value is function, number, or undefined. This, therefore, suggests that these reported values constitute JavaScript types. However, this isn't the case and has been the unfortunate source of personal confusion since my initial contact with JavaScript. This writeup is my attempt to save others the trouble and frustration of getting to a definite list of data types in JavaScript.


There is an international body called Ecma International comprised of technical experts who specify how JavaScript interpreters (should) work. They produce authoritative detailed technical instructions on how JavaScript code should be understood by the computer. Every year they expand the language, adding new features and making the language more powerful. ES6 was the first of the most recent series of annual improvements - this particular version came out in 2015 - that introduced many exciting features to the language, among which is the latest addition to the roster of JavaScript data types. According to specification, there are currently 7 data types in JavaScript:

Primitive data types
Undefined
Null
Boolean
String
Symbol (introduced in ES6)
Number
Complex data type
Object

So what's up with typeof reporting function as a value? Well, it turns out that typeof has multiple bugs that were never fixed due to backward compatibility. function being reported as one of the values is just one of those backward compatibility issues we're stuck with.