1.函数作为参数进行传递
function a(str,fun){
console.log(fun(str))
};
function up(str){
return str.toUpperCase();
};
function down(str){
return str.toLowerCase();
};
a(‘Hello,World !‘,up) //HELLO,WORLD !
a(‘Hello,World !‘,down) //hello,world !
原文:http://www.cnblogs.com/cainiaoz/p/5509902.html