functions are object in javascript?

javascript

Solution

That's because the direct type of a function is `"function"`.

However, you missed this assertion:

fn instanceof Object // true

Btw, types such as `"number"` and `"string"` are strictly not descendants of `Object`, even though they are like objects in the sense that they have methods; just one of those things that makes JavaScript interesting :)

See also: `typeof` and its range of values.

Problem

``` var obj = {}; var fn = function(){}; obj.prop = "some value"; fn.prop = "some value"; assert( obj.prop == fn.prop, "Both are objects, both have the property." ); assert(typeof(obj) === 'object', "Yes its an object"); assert(typeof(fn) === 'object', "why is this not an object"); ``` I heard from some people around that `functions are objects` and this is what i am believing so far, but why is the first condition `passes` well and third one `fails`.

Original source