![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
凌晨两点半`
人生苦短,及时行乐
展开
-
一个方法同时满足 sum(2,3)=== sum(2)(3)
箭头函数let sum=(...n)=>{ if(n.length===2){ return n[0] + n[1] }else{ return (m)=>n[0]+m }}console.log(sum(2,3));console.log(sum(2)(3))普通函数 function sum() { var som = arg...原创 2019-02-15 09:22:38 · 815 阅读 · 0 评论 -
js监听浏览器变化的函数,大于500px时,打印console.log('hello'),且只打印一次
let str = ''; window.onresize = function(){ if(document.body.clientWidth>= 500){ if(str === ''){ str='hello'; console.log(str); }else{ return; } } }原创 2019-03-23 10:32:08 · 683 阅读 · 0 评论