![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JavaScript
深斗士
我很懒,懒得coding
展开
-
Es6 函数操作小记录
1.forEach var arr = [1,2,3,4]; arr.forEach((item,index,arr) => { console.log(item) //结果为1,2,3,4 }) //forEach遍历数组,无返回值,不改变原数组,仅仅只是遍历、常用于注册组件、指令等等。 2.map() var arr = [1,2,3,4]; arr.map((item,index,arr) => { return item*10 /原创 2021-04-12 17:12:55 · 84 阅读 · 0 评论 -
Js实现订阅发布模式(让你的代码写得贼六)
简单例子 var salesoffice = {}; //定义售楼处 salesoffice.clientList = []; //缓存列表,存放订阅者的回调函数 salesoffice.listen = function (key,fn) { //增加订阅者 if(!this.clientList[key]){ this.cl...原创 2017-11-17 10:05:37 · 5127 阅读 · 1 评论 -
Javascript创建对象的5种姿势
/* Start and stop animations using functions. */ function startAnimation() { alert('startAnimation'); } function stopAnimation() { alert('stopAnimation'); } /* Anim class. */ var Anim = func...原创 2017-11-17 10:04:40 · 188 阅读 · 0 评论