javascript函数式编程风格

对一些常见的操作进行包装,以便我们的代码更具有“函数式”的风格

function abs(x){return x>0?x:-x;}
function add(a,b){return a+b;}
function sub(a,b){return a-b;}
function mul(a,b){return a*b;}
function div(a,b){return a/b;}
function rem(a,b){return a%b;}
function inc(x){return x+1;}
function dec(x){return x-1;}
function equal(a,b){return a==b;}
function great(a,b){return a>b;}
function less(a,b){return a<b;}
function negative(x){return x<0;}
function positive(x){return x>0;}
function sin(x){return Math.sin(x);}
function cos(x){return Math.cos(x);}
原文地址:https://www.cnblogs.com/tuya/p/3026541.html