- 博客(5)
- 收藏
- 关注
原创 js的36个设计模式:技巧型模式
1.链模式通过return this,让函数对象可以链式调用。function fn(){ this.a = function(){ console.log("a"); return this; }; this.b = function(){ cosnole.log("b"); return this;
2017-04-21 13:29:59 477
原创 js的36个设计模式:行为型模式
1.模板方法模式不太好描述,就类似封装一个插件,传入不同参数和函数,实现添加dom的样式和方法。2.观察者模式跳过3.状态模式把多个判断封装到函数内。var a = "run"; function action(a){ if(a == "run"){ //code }else if(a == "jump"){ //code }else if(a
2017-04-21 13:29:19 910
原创 原生js实现复制浏览器内容
<!DOCTYPE html> <html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> </head><body> <div id="con">需要复制的文字</div> <br> <input type="button" name="" value="点击复制" onclic
2017-04-21 13:28:34 4857 2
原创 es2015
//1.let 只在作用域内有效 let name = "a";function fn() { let name = "b"; console.log(name); //b }fn(); console.log(name); //a//2.const 用来声明常量,一但声明就无法改变 const a = "a"; //a = "b"; console.log(a); //3.class 类
2017-04-21 13:23:53 393
原创 js实现lazyman(流程控制)
function _lazyMan(name) { this.name = name; this.task = []; this.default(); var _this = this; setTimeout(function() { _this.next(); }, 0) } _lazyMan.prototype.next = fun
2017-04-21 13:22:59 1167
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人