javascriptµÄcurryingº¯Êý
curryingº¯ÊýÊÇÒ»ÖÖ·µ»Øº¯ÊýµÄº¯Êý£¬ÊDZհü×îΰ´óµÄÓ¦ÓÃÖ®Ò»¡£Óйرհü¸üÏêϸµÄ¶¨Òå¿É²Î¼ûÕâÀïÓëÕâÀï¡£ÈçÏÂcurryingº¯ÊýµÄÒ»ÖÖ¶¨Òå¡£
×îÔçÆÚµÄcurryº¯ÊýÓеã¶à̬µÄÒâ棬¾ÍÊǸù¾Ýº¯Êý²ÎÊýÔÚÄÚ²¿Ñ¡Ó÷ÖÖ§£º
//http://www.openlaszlo.org/pipermail/laszlo-user/2005-March/000350.html
// ¡ï¡ïOn 8 Mar 2005, at 00:06, Steve Albin wrote:
function add(a, b) {
if (arguments.length < 1) {
return add;
} else if (arguments.length < 2) {
return function(c) { return a + c }
} else {
return a + b;
}
}
var myadd = add( 2 );
var total = myadd(3);
ÈÕ±¾µÄÒ»¸öÏÈÐÐÕß¿ÉÄÜÔÚδ¸ãÇåargumentsÒ²ÄÜÓÃArrayµÄÔÉú·½·¨×ª»»ÎªÊý×éµÄʱºò£¬Ó÷dz£¸´ÔÓµÄÕýÔòÓëeval¸ã³öÒ»¸ö¸ü½Ó½üÏÖ´úcurryingÒâζµÄº¯Êý¡£
function curry(fun) {
if (typeof fun != 'function') {
throw new Error("The argument must be a function.");
}
if (fun.arity == 0) {
throw new Error("The function must have more than one argument.");
}
var funText = fun.toString();
var args = /function .*\((.*)\)(.*)/.exec(funText)[1].split(', ');
var firstArg = args.shift();
var restArgs = args.join(', ');
var body = funText.replace(/function .*\(.*\) /, "");
var curriedText =
"function (" + firstArg + ") {" +
"return function (" + restArgs + ")" + body +
"}";
eval("var curried =" + curriedText);
return curried;
}
function curry(fun) {
if (typeof fun != 'function') {
throw new Error("The argument must be a function.");
}
if (fun.arity == 0) {
throw new Error("The function must have more than one argument.");
}
var funText = fun.toString();
var args = /function .*\((.*)\)(.*)/.exec(funText)[1].split(', ');
var firstArg = args.shift();
var restArgs = args.join(', ');
var body = funText.r
Ïà¹ØÎĵµ£º
ÔÚJavaScriptÖÐ×Ö·û´®ÊÇÓÃÒýºÅ“" "”¡¢“' '”°üÆðÀ´µÄÁã¸öÖÁ¶à¸ö×Ö·û¡£ÓÃÄĸöÒýºÅ¿ªÊ¼¾ÍÓÃÄĸö½áÊø£¬¶øÇÒµ¥Ë«ÒýºÅ¿ÉǶÌ×ʹÓ㬲»¹ýJavaScript ÖÐÒýºÅµÄǶÌ×Ö»ÄÜÓÐÒ»²ã¡£Èç¹ûÏëÔÙ¶àǶһЩ£¬ÐèÒªÓÃתÒå×Ö·û£º
תÒå×Ö·û ÓÉÓÚһЩ×Ö·ûÔÚÆÁÄ»Éϲ»ÄÜÏÔʾ£¬»òÕß JavaScript Óï·¨ÉÏÒѾÓÐÁËÌØÊâÓÃ;£¬ ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......
±¾ÎÄÀ´×Ô£ºhttp://forum.sysmu.com/thread-394-1-1.html
ÍøͨÏß·,²¿·ÖÎļþÏÂÔرȽÏÂý,ÍûÁ½â! 7 P+ q$ K. }0 ^$ l1 b
µÚÒ»²¿·Ö: htmlÓïÑÔ»ù´¡
ftp://edu:edu@ftp.hyperedu.cn:2003/ÊÓƵ½Ìѧ1Çø/JavaScriptÕÅТÏé/01-01.rmvb
fftp://edu:edu@ftp.hyperedu.cn:2003/ÊÓƵ½Ìѧ1Çø/JavaScriptÕÅТÏé/01-02.rm ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......
£¨×¢£ºÒÔϹ¤¾ßµÄ½éÉÜת×ÔJAVAEYE 2Ô¿¯£©
¡¡¡¡½ñÌìÔÚJavaEye 2Ô¿¯ÉÏ¿´µ½Õâƪ×ܽáJavaScriptµÄÎÄÕ£¬¾õµÃдµÄºÜºÃ£¬ÏÖ°ÑÕâЩ¹¤¾ßµÄ½éÉÜתÔعýÀ´×ö¹ý±£´æ£¬ÒÔºóÓõ½µÄ»°Ò²¿ÉÒÔ²éѯ²éѯ:-P
¡¡¡¡ÔÚAJAXÁ÷ÐеĽñÌìºÜ´ó³Ì¶ÈÉϹ鹦ÓÚJavaScript£¬Èç¹ûûÓÐJS£¬ÏàÐÅAJAXÒ²ÎÞ´Ó̸Æð¡£JavaScriptÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ¿Í»§¶Ë½Å±¾ÓïÑÔ£¬Ë ......