mozilla

Compare Revisions

About JavaScript

Change Revisions

Revision 6618:

Revision 6618 by jsx on

Revision 6619:

Revision 6619 by Sonrisa on

Title:
About JavaScript
About JavaScript
Slug:
JavaScript/About_JavaScript
JavaScript/About_JavaScript
Tags:
javascript
javascript
Content:

Revision 6618
Revision 6619
n8      What is JavaScript?n8      什麼是 JavaScript?
n11      <span class="external">JavaScript</span><sup>®</sup> is then11      <span class="external">JavaScript</span><sup>® &nbsp;</sup>
> Netscape-developed object scripting language used in millions of>是被用在上百萬的網頁和伺服器應用程式的一種網景開發物件腳本語言。Netscape's JavaScript是ECMA-262 Ed
> web pages and server applications worldwide. Netscape's JavaScri>ition 3 (<a href="/en/JavaScript/Language_Resources" title="en/EC
>pt is a superset of the ECMA-262 Edition 3 (<a href="/en/ECMAScri>MAScript">ECMAScript</a>)的基礎標準腳本語言,兩者之間<span>從</span><span>公佈的標準<
>pt" title="en/ECMAScript">ECMAScript</a>) standard scripting lang>/span><span>只有輕微</span><span>的</span><span>差異</span><span>。</span
>uage, with only mild differences from the published standard.>>
n14      Contrary to popular misconception, JavaScript is not "Intern14      相對於常見的誤解,<span>JavaScript</span><span>不是</span><span class=
>pretive Java". In a nutshell, JavaScript is a dynamic scripting l>"atn">“</span><span>解釋型的Java</span><span class="atn">”</span><spa
>anguage supporting <a href="/en/JavaScript/Guide/Details_of_the_O>n>。</span><span>簡言之</span><span>,</span><span>JavaScript是一種</span
>bject_Model#Class-Based_vs._Prototype-Based_Languages" title="en/>><span>動態</span><span>的腳本語言</span><span>,</span><span>支持</span><s
>Core_JavaScript_1.5_Guide/Details_of_the_Object_Model#Class-Based>pan>基於原型的物件結構</span><span>。</span><span>基本語法</span><span>是</span>
>_vs._Prototype-Based_Languages">prototype based</a> object constr><span>故意</span><span>類似</span><span>Java和</span><span>C + +來</spa
>uction. The basic syntax is intentionally similar to both Java an>n><span>減少</span><span>需要</span><span>學習語言</span><span>的</span><s
>d C++ to reduce the number of new concepts required to learn the >pan>新</span><span>概念</span><span>。</span><span>語言結構,</span><span>
>language. Language constructs, such as if statements, for and whi>如</span><span>if語句</span><span>,</span><span>for和while迴圈,和選擇</spa
>le loops, and switch and try ... catch blocks function the same a>n><span>,並嘗試</span><span>...</span>&nbsp;<span class="hps">catch塊
>s in these languages (or nearly so.)>的功能</span><span>在這些</span><span>語言</span><span>中</span><span>的</s
 >pan><span>相同</span><span>(</span><span>或接近</span><span>)</span><s
 >pan>。</span>
n17      JavaScript can function as both a <a class="external" href=n17      <span>JavaScript可以</span><span>作為</span><span>一個程序</span><s
>"http://en.wikipedia.org/wiki/Procedural_programming" title="http>pan>和</span><span>一個物件導向</span><span>的語言</span><span>。</span><spa
>://en.wikipedia.org/wiki/Procedural_programming">procedural</a> a>n>創建物件</span><span>的JavaScript</span><span>編程</span><span>,</span
>nd an <a class="external" href="/en/Introduction_to_Object-Orient>><span>通過</span><span>附加</span><span>的方法和屬性</span><span>,否則</span
>ed_JavaScript" title="https://developer.mozilla.org/en/Introducti>><span>空物件</span><span>在運行時</span><span>,而不是</span><span>編譯語言</sp
>on_to_Object-Oriented_JavaScript">object oriented language</a>. O>an><span>如C + +</span><span>和Java</span><span>中</span><span>常見</s
>bjects are created programmatically in JavaScript, by attaching m>pan><span>語法</span><span>類定義</span><span>。</span><span>一旦</span><
>ethods and properties to otherwise empty objects <strong>at run t>span>已建成</span><span>一個物件</span><span>,</span><span>它可以被</span><s
>ime</strong>, as opposed to the syntactic class definitions commo>pan>用來</span><span>作為</span><span>創建</span><span>類似的物件</span><spa
>n in compiled languages like C++ and Java. Once an object has bee>n>的</span><span>藍圖</span><span>。</span>
>n constructed it can be used as a blueprint (or prototype) for cr 
>eating similar objects. 
n20      JavaScript's dynamic capabilities include runtime object con20      <span>JavaScript的</span><span>動態能力包括</span><span>運行時物件的結構</
>nstruction, variable parameter lists, function variables, dynamic>span><span>,</span><span>可變參數列表</span><span>,</span><span>函數變量</s
> script creation (via <code><a href="/en/JavaScript/Reference/Glo>pan><span>,</span><span>動態</span><span>腳本創建</span><span>(透過</span
>bal_Objects/eval" title="en/Core_JavaScript_1.5_Reference/Global_>><span>eval</span><span>)</span><span>,物件自我檢查</span><span>(透過</sp
>Functions/eval">eval</a></code>), object introspection (via <code>an>&nbsp;<code>for ... in</code><span>)</span><span>,原始</span><sp
>>for ... in</code>), and source code recovery (JavaScript program>an>碼</span><span>恢復(</span><span>JavaScript程序</span><span>可以將函式反編
>s can decompile function bodies back into their source text)>譯回原始碼</span><span>)</span>
n23      Intrinsic objects are <code>Number</code>, <code>String</con23      <span>內在</span><span>的</span><span>對象是</span><span>數字,字符串</
>de>, <code>Boolean</code>, <code>Date</code>, <code>RegExp</code>>span><span>,</span><span>布林</span><span>,日期</span><span>,</span>&
>, and <code>Math</code>.>nbsp;<font face="Courier New, Andale Mono, monospace"><span style
 >="line-height: normal;">正規表示法</span></font><span>和數學</span><span>
 >。</span>
n26      For a more in depth discussion of JavaScript programming fon26      <span>更</span><span>深入討論</span><span>JavaScript編程</span><sp
>llow the <a href="#JavaScript_resources">JavaScript resources</a>>an>遵循</span><span>下面</span><span>的JavaScript資源</span>
> links below. 
27    </p>
28    <p>
29      &nbsp;
n29      What JavaScript implementations are available?n32      <span>JavaScript的應用</span><span>有哪些?</span>
n32      mozilla.org hosts two JavaScript implementations. The firstn35      <span>mozilla.org主持</span><span>兩個JavaScript應用</span>。<span
> <strong>ever</strong> JavaScript was created by Brendan Eich at >>有史以來第一次</span>創建JavaScript是在<span>Netscape的</span><span>布倫丹·</sp
>Netscape, and has since been updated (in JavaScript 1.5) to confo>an><span>艾希</span>,並已被更新(在JavaScript1.5)<span>,以符合</span>ECMA-262
>rm to ECMA-262 Edition 5. This engine, code named <a href="/en/Sp>第5<span>版</span><span>。</span><span>這台發動機</span>,代號為SpiderMonkey的
>iderMonkey" title="en/SpiderMonkey">SpiderMonkey</a>, is implemen>,在C中<span>實行。</span>Rhino引擎,主要由Norris Boyd(也在網本<span>)</span><spa
>ted in C. The <a href="/en/Rhino" title="en/Rhino">Rhino</a> engi>n>創建</span><span>是</span><span>在Java中</span>的<span>JavaScript實行</
>ne, created primarily by Norris Boyd (also at Netscape) is a Java>span>。像SpiderMonkey一樣,Rhino是<span>ECMA</span>-262<span>第3版</span>
>Script implementation in Java. Like SpiderMonkey, Rhino is ECMA-2><span>標準</span><span>。</span>
>62 Edition 3 compliant. 
n35      Several optimizations such as TraceMonkey (Firefox 3.5), Jän38      <span>SpiderMonkey的</span>JavaScript引擎<span>不時</span><span>
>gerMonkey (Firefox 4) and IonMonkey were added to the SpiderMonke>被添加到</span><span>一些優化</span>,如的TraceMonkey<span>(</span><span>火狐3
>y JavaScript engine from time to time.>.5</span><span>)</span><span>,</span><span>JägerMonkey</span><spa
 >n>(</span><span>火狐4</span>)<span>和</span><span>IonMonkey</span><s
 >pan>的</span><span>。</span>
n38      <br>n41      <span>除了上述</span><span>的</span><span>實現</span><span>,也有</sp
 >an><span>其他</span><span>如</span><span>流行的JavaScript</span><span>引
 >擎:</span><span>&nbsp;-&nbsp;</span>
39      Besides the above implementations, there are other popular 
>JavaScript engines such as:- 
n42      <li>Google's <a class=" external" href="http://code.google.n44      <li>
>com/p/v8/" title="http://code.google.com/p/v8/">V8</a>, which is  
>used in the Google Chrome browser. 
45        <span>谷</span><span>歌</span><span>的</span>V8引擎,這是谷歌Chrome
 >瀏覽器使用的。
n44      <li>The <a class=" external" href="http://www.webkit.org/prn47      <li>JavaScriptCore被用在一些WebKit瀏覽器中,<span>如</span><span>蘋果的Sa
>ojects/javascript/index.html" title="http://www.webkit.org/projec>fari</span>
>ts/javascript/index.html">JavaScriptCore</a> (SquirrelFish/Nitro) 
> used in some WebKit browsers such as Apple Safari. 
n47        <a class=" external" href="http://my.opera.com/ODIN/blog/n50        <span>carakan在Opera。</span>
>carakan-faq" title="http://my.opera.com/ODIN/blog/carakan-faq">Ca 
>rakan</a> in Opera. 
n51      The <a class=" external" href="http://en.wikipedia.org/wikin54      在Internet Explorer中<span>使用</span><span>的</span>Chakra引擎,在技
>/Chakra_%28JScript_engine%29" title="http://en.wikipedia.org/wiki>術上是一個JScript引擎,而不是一個JavaScript引擎。
>/Chakra_%28JScript_engine%29">Chakra</a> engine used in Internet  
>Explorer is technically a JScript engine, rather than a JavaScrip 
>t engine. 
n54      Each mozilla.org JavaScript engine exposes a public API appn57      <span>每個mozilla.org的JavaScript</span><span>引擎</span><span>,
>lications can call on for JavaScript support. By far, the most co></span><span>暴露</span><span>了一個公共API</span><span>應用程序可以調用</span><
>mmon host environment for JavaScript is web browsers. Web browser>span>的JavaScript支持</span>。<span>到目前為止,</span><span>最常見的</span><sp
>s typically use the public API to create 'host objects' responsib>an>宿主環境</span><span>為JavaScript</span>是網路瀏覽器。 網路<span class="hps"
>le for reflecting the <a class="external" href="http://www.w3.org>>瀏覽器</span>通常使用公共API來創建<span class="atn">“宿主對象”</span><span>負責</s
>/DOM/">DOM</a> into JavaScript.>pan><span>反映</span>DOM到JavaScript。
n57      Another common application for JavaScript is as a (web) sern60      <span>另一個</span><span>常見的應用是</span>為JavaScript(<span>Web)伺服
>ver side scripting language. A JavaScript web server would expose>器</span>端腳本語言。<span>一個JavaScript</span><span>的Web服務器</span><span>
> host objects representing a HTTP request and response objects, w>會暴露</span>主機對象<span>代表</span><span>一個HTTP請求</span>和響應物件,<span>由Ja
>hich could then be manipulated by a JavaScript program to dynamic>vaScript</span>動態<span>生成網頁</span><span>的</span><span>程序</span><s
>ally generate web pages.>pan>操作</span><span>。</span>
n60      For more information on embedding JavaScript in your own apn63      <span>對於</span><span>在</span><span>自己的應用程序</span>中嵌入<span>J
>plications, follow either the SpiderMonkey or Rhino links below, >avaScript</span><span>的</span><span>詳細</span>信息,<span>下面的SpiderMo
>or visit us on the netscape.public.mozilla.jseng newsgroup.>nkey</span><span>或</span><span>Rhino鏈接</span><span>下面</span><span
 >>,</span><span>或</span>訪問我們的上<span>netscape.public.mozilla.jseng<
 >/span><span>新</span>
n66      JavaScript resourcesn69      JavaScript資源
n72      <dd>n75      <dt>
73        Information specific to JavaScript in C engine (aka Spide76        &nbsp; &nbsp; 嵌入到JavaScript的具體信息在C引擎
>rMonkey) embedding. 
74      </dd>77      </dt>
n80      <dd>n83      <dt>
81        Information specific to the JavaScript implementation wri84        &nbsp; &nbsp; 在Java編寫的JavaScript執行的具體信息。&nbsp;(aka Rhino)
>tten in Java (aka Rhino).>.
82      </dd>85      </dt>
n88      <dd>n91      <dt>
89        Pointers to published JavaScript standards, LiveConnect d92        &nbsp; &nbsp; 指針出版的JavaScript標準,LiveConnect文檔和JavaScript 
>ocuments, and work on JavaScript 2.0.>2.0的工作。
90      </dd>93      </dt>
n97        Information on the the high-performance, open-source virtn100        <span>信息</span><span>上</span><span>的</span><span>高性能,</sp
>ual machine for JavaScript 2.0.>an><span>開放原始碼</span><span>JavaScript 2.0的</span><span>虛擬機</span>
 ><span>。</span>
n105        <a href="/en/JavaScript/Guide" title="en/Core_JavaScript_n108        <span>核心JavaScript</span><span>1.5</span><span>指南</span><
>1.5_Guide">Core JavaScript 1.5 Guide</a> and <a href="/En/Core_Ja>span>和</span><span>核心JavaScript</span>1.5參考
>vaScript_1.5_Reference" title="en/Core_JavaScript_1.5_Reference"> 
>Core JavaScript 1.5 Reference</a> 
n113        Pointers to JavaScript scripting resources, including recn116        <span>JavaScript腳本</span><span>資源</span><span>的</span><sp
>ommended reading, online references and tutorials, and sample cod>an>指針</span><span>,</span><span>包括</span><span>推薦閱讀</span><span>,
>e.></span><span>在線參考</span><span>和</span><span>教程</span><span>和示例代碼<
 >/span>
n121        Lists other projects using the open source JavaScript engn124        <span>使用</span><span>開源</span><span>JavaScript引擎</span><s
>ines.>pan>列出</span><span>的其他項目</span><span>。</span>
n129        Information about the core JavaScript test suite.n132        <span>核心</span><span>JavaScript測試</span><span>套件</span><s
 >pan>的</span><span>信息</span><span>。</span>
n137        The newsgroup for discussion about the <strong>JavaScriptn140        <span>新聞組</span><span>討論</span><span>有關</span><span>JavaS
> engines</strong>.>cript引擎</span>。
n143        The newsgroup for general discussion about ECMAScript, mon146        <span>有關</span><span>ECMAScript的</span>,大多(雖然不一定)的一般性討論的新
>stly (though not necessarily) as it pertains to browsers.>聞組,<span>因為它涉及到</span><span>瀏覽器</span><span>。</span>
t147      JavaScript is a trademark or registered trademark of Sun Mit150      <span>JavaScript是</span><span>在美國和</span><span>其他</span><sp
>crosystems, Inc. in the U.S. and other countries.>an>國家</span><span>的</span><span>Sun Microsystems公司</span><span>的商
 >標或</span><span>註冊商標</span><span>。</span>

Back to History