Skip to Content
JAVASCRIPT網頁應用程式設計
book

JAVASCRIPT網頁應用程式設計

by Alex MacCaw
January 2013
Intermediate to advanced
332 pages
5h 23m
Chinese
GoTop Information, Inc.
Content preview from JAVASCRIPT網頁應用程式設計
MVC 和類別(Classes
|
7
由此可見,開發控制器時並不需要使用函式庫或框架平台(framework)。不過得要將控
制器、模型、檢視器三者之間的權責切割乾淨,才能正確的呈現 MVC 架構。本書第四
章會更詳盡的說明控制器和狀態的概念。
邁向模組化的第一步:建立類別
在觸及 MVC 的核心之前,本書首先要介紹一些基本概念,像是 JavaScript 的類別
class)和事件(event)。先打好紮實的基礎,稍後學習進階概念時才能更得心應手。
如果只是想建立一個用來儲存靜態資料的類別,JavaScript 的物件實字(object literal
就足以滿足我們的需求。但我們通常還會需要建立一個可以繼承、可以建立實體的
標準類別。在此需要先鄭重聲明一點,由於 JavaScript 是一種原型語言(prototype
language),因此它本身並沒有提供建立類別的機制。不過,其實我們可以透過一些其他
的手法,輕易的達到和建立類別相同效果的目的。
不少人認為在 JavaScript 程式裡使用類別似乎不符合「JavaScript 精神」(不過我認為這
個詞基本上一點意義也沒有)。如果你是選用 jQuery 函式庫來開發 JavaScript 程式,就
會發現 jQuery 對於該選用哪種架構方法論或繼承模式,是保持著非常中立的立場。這讓
JavaScript 程式設計師誤以為他們不應該考慮程式架構(因為他們會認為 JavaScript
有類別這樣的機制,或是不該使用類別機制)。但事實上 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

Ethan Brown, 武舎 広幸, 武舎 るみ
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre
Strange Code

Strange Code

Ronald T. Kneusel
Perfecting Your Thinking Skills

Perfecting Your Thinking Skills

MIT Sloan Management Review

Publisher Resources

ISBN: 9789862766811