15. 终端性能 CPU 运算 V8 来自 Google 的基于 C++ 的高性能 JavaScript 引擎 Worker API 多线程 JavaScript 运行机制 GPU 硬件加速 Canvas 绘图加速 Video API 解码加速 DOM 渲染加速 移动终端的超强交互性能
16. 终端性能 存储机制 Cookies localStorage sessionStorage Web SQL Cache 交互机制 WebSocket Message Model Ajax Level 2 …… 不仅不能避免缓存, 而且要主动存储! 不要让 Web 成为 Long Polling 的天下!
29. var Person = Backbone.Model.extend({ sayHello : function () { console.log(this.get('name')); } }); var me = new Person({name: 'Will'}); me.sayHello(); // -> 'Will'
30. var People = Backbone.Collection.extend({ sayHello : function () { this.map(function (person) { return this.get('name') + 'say: "Hello, I`m ' + this.get('name') + '."'; }); } }); var w3ctech = new People; w3ctech.add({name: 'Will'}, {name: 'Foo'}, {name: 'Bar'}); w3ctech.sayHello(); /** -> Will say: "Hello, I`m Will." * Foo say: "Hello, I`m Foo." * Bar say: "Hello, I`m Bar." **/
34. Mustache.js var obj = { peoples : [ { Name : 'Will' , Age : 15 , Sex : 'Man' }, { Name : 'Foo' , Age : 30 , Sex : 'Woman' }, { Name : 'Bar' , Age : 18 , Sex : 'Man' }], Man : function () { if ( this . Sex == 'Man' ) { return function ( text , render ) { render ( text ); } } } }; 对象
35. Web.js with Mustache.js var getRouter = { '^mans' : function ( req , res , qs ) { mansHtml = web . render ( 'mans' , obj ); res . send ( mansHtml ); } }; web . set ( 'tmplDir' , 'tmlps' ) . get ( getRouter );
37. Web.js var postRouter = { 'seturlrouter' : function ( req , res , qs ){ web . get ({ qs . key : qs . value }); res . send ( 'Set success' ); } }; web . post ( postRouter );