每日思考(2020/03/04)

时间:2020-03-05 00:42:43   收藏:0   阅读:57

题目概览

题目解答

对HTML5的download属性的理解

inline、block、inline-block这三个属性值有什么区别?

写一个方法,使得sum(x)(y)和sum(x,y)返回的结果相同

//方法1
var sum= function(x){
    if(arguments[1]){
        return x + arguments[1];
    }else{
        return function (y){
            return x + y
        }
    }
}
console.log(sum(1)(2))//3
console.log(sum(1,2))//3

//扩展
function sum(x){
    if(arguments[1]){
        var arr = Array.prototype.slice.apply(arguments);
            x = arr.reduce((a, c)=> a+ c)
        return x;
    }else{
        function add(b) { 
            x = x + b; 
            return add;
        }
        add.toString = function() { 
            return x;
        }
        return add; 
    }
}
var res1 = sum(1)(2)(3)(4)(5)(6);
var res2 = sum(1,2,3,4,5,6);
console.log(res1)//21
console.log(res2)//21

对浏览器的关键渲染路径的理解

原文:https://www.cnblogs.com/EricZLin/p/12416851.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!