$(".signup").click(function(event){
$("#signupModal").show();
event.preventDefault();
});
var firstTwoLetters = function(words){
return _.map(words,function(word){
return _.first(word,2);
});
};
// ...一点魔法 var firstTwoLetters = map(first(2));
var foo = "bar";
var add = function (a, b) { return a + b; };
var even = function (a) { return a % 2 === 0; };
// capture the old version of the function
var old_even = even;
// assign variable `even` to a new, different function
even = function (a) { return a & 1 === 0; };
var binaryCall = function (f, a, b) { return f(a, b); };
add(1,2) === binaryCall(add, 1, 2); // true
var applyFirst = function (f, a) {
return function (b) { return f(a, b); };
};
var mult = function(a, b) { return a * b; };
var double = applyFirst(mult, 2); double(32); // 64 double(7.5); // 15
var curry2 = function (f) {
return function (a) {
return function (b) {
return f(a, b);
};
};
};
var double = curry2(mult)(2);
// flip the argument order of a function
var flip = function (f) {
return function (a, b) { return f(b, a); };
};
divide(10, 5) === flip(divide)(5, 10);
// true
// return a function that's the composition of two functions...
// compose (f, g)(x) -> f(g(x))
var compose = function (f1, f2) {
return function (x) {
return f1(f2(x));
};
};
// abs(x) = Sqrt(x^2)
var abs = compose(sqrt, square);
abs(-2);
// 2
var logWrapper = function (f) {
return function (a) {
console.log('calling "' + f.name + '" with argument "' + a);
return f(a);
};
};
var app_init = function(config) {
/* ... */
};
if(DEBUG) {
// log the init function if in debug mode
app_init = logWrapper(app_init);
}
// logs to the console if in debug mode
app_init({
/* ... */
});
var createCounter = function () {
var count = 0;
return function () {
return ++count;
};
};
var counter1 = createCounter();
counter1();
// 1
counter1();
// 2
var counter2 = createCounter();
counter2();
// 1
counter1();
// 3
// global scope
var scope = "global";
var foo = function(){
// inner scope 1
var scope = "inner";
var myscope = function(){
// inner scope 2
return scope;
};
return myscope;
};
console.log(foo()());
// "inner"
console.log(scope);
// "global"
// global scope...
var names = ['zero','one','two','three','four','five','six','seven','eight','nine'];
var digit_name1 = function(n){
return names[n];
};
var digit_name2 = function(n){
var names = ['zero','one','two','three','four','five','six','seven','eight','nine'];
return names[n];
};
// "An inner function enjoys that context even after the parent functions have returned."
var digit_name3 = (function(){
var names = ['zero','one','two','three','four','five','six','seven','eight','nine'];
return function(n){
return names[n];
};
})();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有