web javascript 架構學習

來源:互聯網
上載者:User

   JS 架構學習

1. Underscore      http://documentcloud.github.com/underscore/
==============================================================
Underscore is a utility-belt library for JavaScript that provides a lot of the 
functional programming support that you would expect in Prototype.js (or Ruby),
but without extending any of the built-in JavaScript objects. It's the tie to 
go along with jQuery's tux.

Table of Contents
-----------------

Object-Oriented and Functional Styles
Collections 
-----------
each, map, reduce, reduceRight, detect, select, reject, all, any, include, 
invoke, pluck, max, min, sortBy, groupBy, sortedIndex, toArray, size

Arrays 
------
first, rest, last, compact, flatten, without, union, intersection, difference,
uniq, zip, indexOf, lastIndexOf, range

Functions 
---------
bind, bindAll, memoize, delay, defer, throttle, debounce, once, after, wrap, compose

Objects 
-------
keys, values, functions, extend, defaults, clone, tap, isEqual, isEmpty, isElement,
isArray, isArguments, isFunction, isString, isNumber, isBoolean, isDate, isRegExp
isNaN, isNull, isUndefined

Utility 
-------
noConflict, identity, times, mixin, uniqueId, template

Chaining 
--------
chain, value

簡單的來說,Underscore 就是一個基礎工具庫,對JavaScript 的一些函數,方法等進行了
封裝, 用來提供函數式編程的特性, 雖然有自己的template輕量級的渲染模板,但不是很好用。

2. mustache         https://github.com/janl/mustache.js
==============================================================
Logic-less templates with JavaScript
Quik start:
->var view = {
->      title: "Joe",
->      calc: function() {
->        return 2 + 4;
->      }
->}
->var template = "{{title}} spends {{calc}}";
->var html = Mustache.to_html(template, view);

非常簡潔直觀的template模板渲染工具。功能強大文法簡潔。好的沒得說。

3. Prototype        http://prototypejs.org/
===========================================
Prototype is a JavaScript framework that aims to ease development of dynamic web
applications. It offers a familiar class-style OO framework, extensive Ajax 
support, higher-order programming constructs, and easy DOM manipulation.

這個主要包含了 Ajax相關的,擴充DOM 其中,擴充DOM是核心, 它使得DOM訪問更物件導向
話,也就是說,將物件導向的更多屬性集成到了js, 包括繼承等。

4. Backbone         http://documentcloud.github.com/backbone/
============================================================
Backbone supplies structure to JavaScript-heavy applications by providing models
with key-value binding and custom events, collections with a rich API of enumerable
functions, views with declarative event handling, and connects it all to your 
existing application over a RESTful JSON interface.

Events

    – bind
    – unbind
    – trigger

Model

    – extend
    – constructor / initialize
    – get
    – set
    – escape
    – has
    – unset
    – clear
    – id
    – cid
    – attributes
    – defaults
    - toJSON
    – fetch
    – save
    – destroy
    – validate
    – url
    – urlRoot
    – parse
    – clone
    – isNew
    – change
    – hasChanged
    – changedAttributes
    – previous
    – previousAttributes

Collection

    – extend
    – model
    – constructor / initialize
    – models
    – toJSON
    – Underscore Methods (26)
    – add
    – remove
    – get
    – getByCid
    – at
    – length
    – comparator
    – sort
    – pluck
    – url
    – parse
    – fetch
    – reset
    – create

Router

    – extend
    – routes
    – constructor / initialize
    – route
    – navigate

History

    – start

Sync

    – Backbone.sync
    – Backbone.emulateHTTP
    – Backbone.emulateJSON

View

    – extend
    – constructor / initialize
    – el
    – $ (jQuery or Zepto)
    – render
    – remove
    – make
    – delegateEvents

Utility

    – noConflict

簡單的說,就是backbone提供了一套比較完整的在JS裡邊使用MVC的架構。適合大型應用,例如
WEB2.0 網站。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.