Front-end Job Interview Questions

Front-end Job Interview Questions

前端面试

https://github.com/h5bp/Front-end-Developer-Interview-Questions

https://github.com/MaximAbramchuck/awesome-interview-questions

https://thatjsdude.com/interview/index.html

http://caibaojian.com/fedbook/practice/front-end-interview.html


柯里化函数


function curry(fn) {
    var slice = [].slice;
    var len = fn.length;

    return function curried() {
        var args = slice.call(arguments);
        if (args.length >= len) {
            return fn.apply(null, args);
        }

        return function () {
            return curried.apply(null, args.concat(slice.call(arguments)));
        };
    };
}

var add = curry(function (a, b, c, d) {
    return a + b + c + d;
});

console.log(add(1)(2)(3)(4)); // 10
console.log(add(1, 2, 3)(4)); // 10
console.log(add(1)(2, 3)(4)); // 10

https://segmentfault.com/q/1010000004342477

add(2)(5); // 7 & 柯里化 curry

js 实现, 函数 add(1)(2)(3); 无限极累加


"use strict";

/**
 *
 * @author xgqfrms
 * @license MIT
 * @copyright xgqfrms
 * @created 2019-01-01
 *
 * @description add & curry
 * @augments
 * @example
 *
 */

function add( seed ) {
    function retVal( later ) {
        return add( seed + later );
    }
    retVal.toString = function() {
        return seed;
    };
    return retVal;
}
console.log(add(1)(2)(3).toString());
// 6
console.log(add(1)(2)(3));
// ƒ 6

function addBug(a){
    function s(b){
       a = a+b;
       return s;
    }
    s.toString = function(){return a;}
    return s;
}
console.log(addBug(1)(2)(3)(4));
// ƒ 10

addBug(1);
// ƒ 1
let x = addBug(1)(2);
// ƒ 3
x;
// ƒ 3
alert(addBug(1)(2)(3)(4));
// alert: 10
// true

740516-20190321135901494-1393080795.png

refs

https://llh911001.gitbooks.io/mostly-adequate-guide-chinese/content/ch4.html

https://www.cnblogs.com/pengchen/p/5434705.html

https://www.cnblogs.com/oxspirt/p/5436629.html

https://www.ruanyifeng.com/blog/2015/02/flexible-javascript.html

wat

https://www.destroyallsoftware.com/talks/wat

740516-20190321110913850-837122167.png

740516-20190321111222893-1499738008.png

转载于:https://www.cnblogs.com/xgqfrms/p/10569997.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值