javascript的重要特徵

來源:互聯網
上載者:User

Javascript語言非常重要的一個特徵是:Javascript是基於原型的語言(prototype-based language),而C++、Object Pascal、C#、Java是居於類的語言(class-based language);另外一個重要特性是Javascript是動態語言,而C++等是靜態語言(C#在4.0版本也引入了一些動態特性)。

基於類的語言(Java) 基於原型的語言 (JavaScript)
類和執行個體是獨立的實體概念。 所有的對象都是執行個體。
使用類的定義語句來定義一個類;使用建構函式來執行個體化一個類 使用建構函式來定義和建立一系列對象
使用 new 操作符來建立一個對象 相同
使用類的定義語句來定義一個已存在類的子類,然後建立對象的層級關係。 使用建構函式類建立一個對象,通過指派原形化的對象並使其關聯於已存在的建構函式Construct an object hierarchy by assigning an object as the prototype associated with a constructor function.
Inherit properties by following the class chain.
通過類來繼承屬性
Inherit properties by following the prototype chain.
通過原型來繼承屬性
Class definition specifies all properties of all instances of a class. Cannot add properties dynamically at run time.
類定義了執行個體的所有屬性,不能在運行時動態添加
Constructor function or prototype specifies an initial set of properties. Can add or remove properties dynamically to individual objects or to the entire set of objects.
建構函式或者原型定義了屬性的原創組合,可以在運行時動態添加刪除屬性

 

參考: 

http://en.wikipedia.org/wiki/Prototype_pattern  

http://en.wikipedia.org/wiki/Prototype-based

http://en.wikipedia.org/wiki/JavaScript 

Class-Based vs. Prototype-Based Languages 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.