美文网首页
无标题文章

无标题文章

作者: StrangeOne | 来源:发表于2016-09-20 21:29 被阅读0次

Javascript

1. 请优化这段代码 ,提高可读性

function async_add (m, n, callback) {
    setTimeout(callback.bind(null, m+n), 500);
}

async_add(1, 2, function (res) {
    console.log(res);
    async_add(res, 3, function (res) {
        console.log(res);
        async_add(res, 5, function (res) {
            console.log(res);
            async_add(res, 10, function (res) {
                console.log(res);
                async_add(res, 25, function (res) {
                    console.log(res);
                    async_add(res, 37, function (res) {
                        console.log(res);
                        async_add(res, 48, function (res) {
                             console.log(res);
                        })
                    })
                });
            });
        });
    });
});

2. 请给出这段代码 的运行结果,并解释为什么

class Animal {
    constructor(pos) {
        this.pos = pos;
    }
}

class Whale extends Animal {
constructor(pos) {
    super(pos + 1);
}
swim() {
    this.pos <<= 1;
    setTimeout(function timer() {
    this.pos <<= 1;
    this.pos < 8 && setTimeout(timer, 0);
    console.log(this.pos);
    }, 0);
    console.log(this.pos);
}
}

var pos = 1;
const whale = new Whale(pos);
whale.swim();

3. 请实现下段代码

/**
interface Array<T> {
    //flatMap :: (t -> [u]) -> [t] -> [u]
    flatMap<U>(f: (item: T) => U[]): U[];

}
*/

Array.prototype.flatMap = function (f) {
    // 实现这个函数,使得下面的测试用例能够正确输出
    throw new Error('Not implemented yet!')
    
}


/**
* 测试用例
*/

const arr1 = [1, 2, 3], arr2 = ['a', 'b', 'c']
const CartesianProduct = arr1.flatMap(x => arr2.flatMap(y => [[x, y]]))
//result => [[1, 'a'], [1, 'b'],  [1, 'c'],  [2, 'a'], [2, 'b'], [2, 'c'], [3, 'a'], [3, 'b'], [3, 'c']]


const flattenArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].flatMap(x => x)
//result => [1, 2, 3, 4, 5, 6, 7, 8, 9]

html/css

请根据此效果图,兼容现代浏览器,尽可能还原。 (不限框架,工具,预编译语言)

兼容性要求:Chrome / Firefox / IE 11 / Edge

zenmate_payment.png

相关文章

  • 无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章 无标题文章无标题文章无标题文章无...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • fasfsdfdf

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章 无标题文章 无标题文章无标题文章 无标题文章 无标题文章

网友评论

      本文标题:无标题文章

      本文链接:https://www.haomeiwen.com/subject/eqioettx.html