Here is a simple example of a function and its datatype:
Code Snippet:
function hello(){
console.log("hello");
}
console.log(typeof(hello)); //function
Query:
In JavaScript these are the datatypes:
1. Object
2. Primitives - String, number, boolean, null, undefined, symbol(ECMA6)
When there is no datatype named 'function' then how in the world am I getting the datatype as function (though logically its correct). Also, textually it is written that datatype of function is object. So, I must have got result as object.
Can someone clarify this confusion?
data type"function"is what the spec says to return? (Which makes sense, whereastypeof nullreturns"object".)