功能返回功能??? [英] Function return function???

查看:56
本文介绍了功能返回功能???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

功能F(e)

{

返回

function(){P(e)}

}


有谁可以告诉我代码在做什么?


如果在函数中返回另一个函数我会做

功能F(e)

{

返回P(e)

}


是否定义了另一个函数?我不记得其他语言可以在一个函数中定义另一个函数。程序员为什么要这样做呢?

解决方案

" strout" < ZJ ***** @ hotmail.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...


如果在函数中返回另一个函数我会做什么
函数F(e)
{
返回P(e)
}



返回调用函数P(e)的* result *。


我想问的是这段代码在做什么


函数F(e)

{

返回

function(){P(e)}

}


" strout" < ZJ ***** @ hotmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...

我想问的是这段代码是做什么的

函数F(e)
{
返回
函数(){P (e)}
}




做无法形容的事情,没有人能够支持;-)

http://jibbering.com/faq/faq_notes/closures.html
http://www.svendtofte.com/code/curried_javascript/


function F(e)
{
return
function(){P(e)}
}

Can anybody tell me what the code is doing?

If return another function all in a function I would do
function F(e)
{
return P(e)
}

Is it defining another function? I don''t recall other languages can
define another function inside one function. Why would the programmer
do this?

解决方案

"strout" <zj*****@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...


If return another function all in a function I would do
function F(e)
{
return P(e)
}



That returns the *result* of calling the function P(e).


what i am trying to ask is what''s this code doing

function F(e)
{
return
function(){P(e)}
}


"strout" <zj*****@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

what i am trying to ask is what''s this code doing

function F(e)
{
return
function(){P(e)}
}



To do unspeakable things that no-one will ever be able to support ;-)

http://jibbering.com/faq/faq_notes/closures.html
http://www.svendtofte.com/code/curried_javascript/


这篇关于功能返回功能???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆