function say_yes(){
console.log("yes")
}
Obj={}
Obj=say_yes
Obj.something="something"
Obj.nothing="nothing"
浏览器中
在上面的代码中,如果i console.log(Obj)
,则给出函数表达式在上面的代码中,如果i console.log(Obj.something)
或console.log(Obj.nothing)
,则给出属性值。当我呼叫Obj()
时,它会控制台"yes"
IN NODE在上面的代码中,如果我console.log(Obj),它给出
{ [Function: say_yes] something: 'something', nothing: 'nothing' }
在上面的代码中,如果i console.log(Obj.something)
或console.log(Obj.nothing)
,则给出属性值。当我呼叫Obj()
时,它会控制台"yes"
我真的很困惑,它是Obj的功能吗?是一个对象吗?在看到express框架的module.exports
的源代码后,我对此表示怀疑。
有人可以消除我的疑虑..
function say_yes(){console.log(“ yes”)}} Obj = {} Obj = say_yes Obj.something =“ something” Obj.nothing =“ nothing” IN BROWSER在上面的代码中,如果我console.log(Obj ),它给出...
javascript中的所有函数实际上都是一流的对象。可以调用那些功能对象。您可以在这里阅读:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions