• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 








每日三省吾身
 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 22 下一页

2012年9月21日

Bridge Pattern in Javascript
摘要: 一个比较简洁的例子:functiongetBeerById(e){ varid=this.id;asyncRequest('GET','beer.uri?id='+id,function(resp){console.log('RequestedBeer:'+resp.responseText);});}addEvent(element,'click',getBeerById);这里可以看到,它其实就是为DOM元素的click绑定一个方法,在这个方法里做一个异步请求,然后当请求成功后,log出response结果。 问题在于getB 阅读全文
posted @ 2012-09-21 15:15 渔樵耕读2017 阅读(188) 评论(0) 推荐(0)
 

2012年9月20日

Javascript中Factory的应用
摘要: 这里拿Pro Javascript Design Pattern中的例子作为case。假如一家自行车店销售各种自行车:/*TheBicycleinterface.*/varBicycle=newInterface("Bicycle",["assemble","wash","ride","repair"]);/*Speedsterclass.*/varSpeedster=function(){}Speedster.prototype={assemble:function(){console.log 阅读全文
posted @ 2012-09-20 22:31 渔樵耕读2017 阅读(380) 评论(0) 推荐(0)
 

2012年9月18日

Parallel Programming Easier than ever using .NET Framework 4
摘要: The .NET Framework 4 Provides support for parallel loops and regions easily if you compare to the older versions of .Net such as using System.Threading now with the introduction of the Parallel class it now provides library-based data parallel operations such as for loops, for each loops, and invoke 阅读全文
posted @ 2012-09-18 17:53 渔樵耕读2017 阅读(278) 评论(0) 推荐(0)
 

2012年9月16日

Javascript中chaining的实现
摘要: 如果你了解Jquery,你一定为它的chaining的便利而折服。而它的原理,其实也很简单,不过是每个方法都返回this对象而已。如下:(function($){function_$(elements){this._elements=[];for(vari=0;i<elements.length;i++){if(typeof(elements[i])=="string"){this._elements.push(document.getElementById(elements[i]));}else{this._elements.push(elements[i]);}} 阅读全文
posted @ 2012-09-16 21:59 渔樵耕读2017 阅读(435) 评论(0) 推荐(0)
 

2012年9月14日

Javascript中singleton的实现
摘要: 最好的实现:varlangzi=window.langzi||{};langzi.singleton=window.langzi.singleton||(function(){varinstance=null;varconstructor=function(){return{id:1,name:"test",getMessage:function(){console.log("id:"+this.id+",name:"+this.name);}};};return{getInstance:function(){if(instance= 阅读全文
posted @ 2012-09-14 14:01 渔樵耕读2017 阅读(211) 评论(0) 推荐(0)
 

2012年9月13日

Javascript中怎么实现继承?
摘要: 传统的继承:varPerson=function(name){ this.name=name||"defaultname";if(typeofPerson._initialized=="undefined"){Person.prototype.getName=function(){returnthis.name;};Person._initialized=true;}};varAuthor=function(name,books){Person.call(this,name);this.books=books||[];/*if(typeofAuthor. 阅读全文
posted @ 2012-09-13 16:47 渔樵耕读2017 阅读(218) 评论(0) 推荐(0)
 

2012年9月8日

Javascript中怎么定义类(私有成员、静态成员)?
摘要: 本文将从一个简单例子演绎怎么定义一个具有私有成员、静态成员的类。 好,看简单原型:varBook=function(isbn,title,author){if(isbn===undefined){thrownewError('Bookconstructorrequiresanisbn.');}this.isbn=isbn;this.title=title||'Notitlespecified';this.author=author||'Noauthorspecified';};Book.prototype.display=function(){a 阅读全文
posted @ 2012-09-08 22:52 渔樵耕读2017 阅读(936) 评论(0) 推荐(0)
 
Javascript中如何实现interface机制
摘要: 我们知道,ECMAScript中是没有interface一说的。虽然如此,参考《Pro Javascript Design Pattern》一书,哥算是找到方案了。 最简单的方案,就是通过文档说明了。简称方案1,代码如下:/*interfacecomposite{functionadd(child);functionremove(child);functiongetChild(index);}interfaceformItem{functionsave();}*/varcompositeForm=function(id,name){this.id=id;this.name=name;if(t. 阅读全文
posted @ 2012-09-08 21:53 渔樵耕读2017 阅读(1124) 评论(0) 推荐(0)
 

2012年9月5日

你未必真正了解的Singleton
摘要: 缘于http://www.cnblogs.com/TomXu/archive/2011/12/19/2291448.html这篇文章,发现胖哥对于singleton的分析仍然不是十分深入,借鉴CLR via C#,再次深入完美一下singleton。 经典的double-check locking: publicclassSingleton{privatestaticSingletoninstance;privatestaticreadonlyObjectsyncRoot=newObject();privateSingleton(){}publicstaticSingletonG... 阅读全文
posted @ 2012-09-05 09:40 渔樵耕读2017 阅读(260) 评论(0) 推荐(0)
 

2012年9月1日

浏览器内核的解析和对比
摘要: 要搞清楚浏览器内核是什么,首先应该先搞清楚浏览器的构成。简单来说浏览器可以分为两部分,shell+内核。其中shell的种类相对比较多,内核则比较少。Shell是指浏览器的外壳:例如菜单,工具栏等。主要是提供给用户界面操作,参数设置等等。它是调用内核来实现各种功能的。内核才是浏览器的核心。内核是基于标记语言显示内容的程序或模块。也有一些浏览器并不区分外壳和内核。从Mozilla将Gecko独立出来后,才有了外壳和内核的明确划分。目前主流的浏览器有IE6、IE8、Mozilla、FireFox、Opera、Safari、Chrome、Netscape等。什么是浏览器内核浏览器内核又可以分成两部分 阅读全文
posted @ 2012-09-01 22:21 渔樵耕读2017 阅读(236) 评论(0) 推荐(0)
 
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 22 下一页