functions are object in javascript?

后端 未结 2 1132
故里飘歌
故里飘歌 2021-01-21 04:44
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.\" );
a         


        
2条回答
  •  攒了一身酷
    2021-01-21 05:23

    Functions are objects, but they are a particular type of object. typeof(fn) should evaluate to "function", which is a sub-type of "object".

提交回复
热议问题