JavaScript高级程序设计外文翻译资料

 2022-01-17 09:01

Professional JavaScript for Web Developers

Nicholas C.Zakas

  1. What is JavaScript ?
  2. Review of JavaScript history
  3. What JavaScript is
  4. How JavaScript and ECMAScript are related
  5. The different versions of JavaScript

When JavaScript first appeared in 1995, its main purpose was to handle some of the input validation that had previously been left to server-side languages such as Perl. Prior to that time, a round-trip to the server was needed to determine if a required field had been left blank or an entered value was invalid. Netscape Navigator sought to change that with the introduction of JavaScript. The capability to handle some basic validation on the client was an exciting new feature at a time when use of telephone modems was widespread. The associated slow speeds turned every trip to the server into an exercise in patience.

Since that time, JavaScript has grown into an important feature of every major web browser on the market. No longer bound to simple data validation, JavaScript now interacts with nearly all aspects of the browser window and its contents. JavaScript is recognized as a full programming language, capable of complex calculations and interactions, including closures, anonymous (lambda) functions, and even metaprogramming. JavaScript has become such an important part of the Web that even alternative browsers, including those on mobile phones and those designed for users with disabilities, support it. Even Microsoft, with its own client-side scripting language called VBScript, ended up including its own JavaScript implementation in Internet Explorer from its earliest version.

The rise of JavaScript from a simple input validator to a powerful programming language could not have been predicted. JavaScript is at once a very simple and very complicated language that takes minutes to learn but years to master. To begin down the path to using JavaScriptrsquo;s full potential, it is important to understand its nature, history, and limitations.

1.1 A SHORT HISTORY

As the Web gained popularity, a gradual demand for client-side scripting languages developed. At the time, most Internet users were connecting over a 28.8 kbps modem even though web pages were growing in size and complexity. Adding to usersrsquo; pain was the large number of round-trips to the server required for simple form validation. Imagine fi lling out a form, clicking the Submit button, waiting 30 seconds for processing, and then being met with a message indicating that you forgot to complete a required fi eld. Netscape, at that time on the cutting edge of technological innovation, began seriously considering the development of a client-side scripting language to handle simple processing.

Brendan Eich, who worked for Netscape at the time, began developing a scripting language called Mocha, and later LiveScript, for the release of Netscape Navigator 2 in 1995, with the intention of using it both in the browser and on the server (where it was to be called LiveWire). Netscape entered into a development alliance with Sun Microsystems to complete the implementation of LiveScript in time for release. Just before Netscape Navigator 2 was officially released, Netscape changed LiveScriptrsquo;s name to JavaScript to capitalize on the buzz that Java was receiving from the press.

Because JavaScript 1.0 was such a hit, Netscape released version 1.1 in Netscape Navigator 3. The popularity of the fledgling Web was reaching new heights, and Netscape had positioned itself to be the leading company in the market. At this time, Microsoft decided to put more resources into a competing browser named Internet Explorer. Shortly after Netscape Navigator 3 was released, Microsoft introduced Internet Explorer 3 with a JavaScript implementation called JScript (so called to avoid any possible licensing issues with Netscape). This major step for Microsoft into the realm of web browsers in August 1996 is now a date that lives in infamy for Netscape, but it also represented a major step forward in the development of JavaScript as a language.

Microsoftrsquo;s implementation of JavaScript meant that there were two different JavaScript versions floating around: JavaScript in Netscape Navigator and JScript in Internet Explorer. Unlike C and many other programming languages, JavaScript had no standards governing its syntax or features, and the three different versions only highlighted this problem. With industry fears mounting, it was decided that the language must be standardized.

In 1997, JavaScript 1.1 was submitted to the European Computer Manufacturers Association (Ecma) as a proposal. Technical Committee #39 (TC39) was assigned to “standardize the syntax and semantics of a general purpose, cross-platform, vendor-neutral scripting language” www.ecma-international.org/memento/TC39.htm). Made up of programmers from Netscape, Sun, Microsoft, Borland, NOMBAS, and other companies with interest in the future of scripting, TC39 met for months to hammer out ECMA-262, a standard defining a new scripting language named ECMAScript (often pronounced as “ek-ma-script”).

The following year, the International Organization for Standardization and International Electrotechnical Commission (ISO/IEC) also adopted ECMAScript as a standard (ISO/IEC-16262). Since that time, browsers have tried, with varying degrees of success, to use ECMAScript as a basis for their JavaScript implementations.

1.2 JAVASCRIPT IMPLEMENTATIONS

Though JavaScript and ECMAScript are often used synonymously, JavaScript is much more than just what is defi ned in ECMA-262. Indeed, a complete JavaScript implementation is made up of the following three distinct parts.

  1. The Core (ECMAScript)
  2. The Document Object Model (DOM)
  3. The Browser Object Model (BOM)

1.2.1 ECMAScript<!--

全文共21659字,剩余内容已隐藏,支付完成后下载完整资料


JavaScript高级程序设计(翻译)

[美] 扎卡斯

1、什么是JavaScript?

1) JavaScript 历史回顾

  1. JavaScript 是什么
  2. JavaScript 与 ECMAScript 的关系
  3. JavaScript 的不同版本

JavaScript 诞生于 1995 年。当时,它的主要目的是处理以前由服务器端语言(如 Perl)负责的一 些输入验证操作。在 JavaScript 问世之前,必须把表单数据发送到服务器端才能确定用户是否 没有填写某个必填域,是否输入了无效的值。Netscape Navigator 希望通过 JavaScript 来解决这个问题。 在人们普遍使用电话拔号上网的年代,能够在客户端完成一些基本的验证任务绝对是令人兴奋的。毕竟, 拨号上网的速度之慢,导致了与服务器的每一次数据交换事实上都成了对人们耐心的一次考验。 自此以后,JavaScript 逐渐成为市面上常见浏览器必备的一项特色功能。如今,JavaScript 的用途早 已不再局限于简单的数据验证,而是具备了与浏览器窗口及其内容等几乎所有方面交互的能力。今天的 JavaScript 已经成为一门功能全面的编程语言,能够处理复杂的计算和交互,拥有了闭包、匿名(lamda, 拉姆达)函数,甚至元编程等特性。作为 Web 的一个重要组成部分,JavaScript 的重要性是不言而喻的, 就连手机浏览器,甚至那些专为残障人士设计的浏览器等非常规浏览器都支持它。当然,微软的例子更 为典型。虽然有自己的客户端脚本语言 VBScript,但微软仍然在 Internet Explorer 的早期版本中加入了 自己的 JavaScript 实现。

JavaScript 从一个简单的输入验证器发展成为一门强大的编程语言,完全出乎人们的意料。应该说, 它既是一门非常简单的语言,又是一门非常复杂的语言。说它简单,是因为学会使用它只需片刻功夫; 而说它复杂,是因为要真正掌握它则需要数年时间。要想全面理解和掌握 JavaScript,关键在于弄清楚 它的本质、历史和局限性。

1.1 JavaScript 简史

在 Web 日益流行的同时,人们对客户端脚本语言的需求也越来越强烈。那个时候,绝大多数因 特网用户都使用速度仅为 28.8kbit/s 的“猫”(调制解调器)上网,但网页的大小和复杂性却不断增 加。为完成简单的表单验证而频繁地与服务器交换数据只会加重用户的负担。想象一下:用户填写 完一个表单,单击“提交”按钮,然后等待 30 秒钟,最终服务器返回消息说有一个必填字段没有填好hellip;hellip;当时走在技术革新最前沿的 Netscape 公司,决定着手开发一种客户端语言,用来处理这种 简单的验证。

当时就职于 Netscape 公司的布兰登·艾奇(Brendan Eich),开始着手为计划于 1995 年 2 月发布的 Netscape Navigator 2 开发一种名为 LiveScript 的脚本语言——该语言将同时在浏览器和服务器中使用 (它在服务器上的名字叫 LiveWire)。为了赶在发布日期前完成 LiveScript 的开发,Netscape 与 Sun 公司 建立了一个开发联盟。在 Netscape Navigator 2 正式发布前夕,Netscape 为了搭上媒体热炒 Java 的顺风车, 临时把 LiveScript 改名为 JavaScript。

由于 JavaScript 1.0 获得了巨大成功,Netscape 随即在 Netscape Navigator 3 中又发布了 JavaScript 1.1。 Web 虽然羽翼未丰,但用户关注度却屡创新高。在这样的背景下,Netscape 把自己定位为市场领袖型公 司。与此同时,微软决定向与 Navigator 竞争的自家产品 Internet Explorer 浏览器投入更多资源。Netscape Navigator 3 发布后不久,微软就在其 Internet Explorer 3 中加入了名为 JScript 的 JavaScript 实现(命名为 JScript 是为了避开与 Netscape 有关的授权问题)。以现在的眼光来看,微软 1996 年 8 月为进入 Web 浏览 器领域而实施的这个重大举措,是导致 Netscape 日后蒙羞的一个标志性事件。然而,这个重大举措同时 也标志着 JavaScript 作为一门语言,其开发向前迈进了一大步。

微软推出其 JavaScript 实现意味着有了两个不同的 JavaScript 版本:Netscape Navigator 中的 JavaScript、Internet Explorer 中的 JScript。与 C 及其他编程语言不同,当时还没有标准规定 JavaScript 的 语法和特性,两个不同版本并存的局面已经完全暴露了这个问题。随着业界担心的日益加剧,JavaScript 的标准化问题被提上了议事日程。

1997 年,以 JavaScript 1.1 为蓝本的建议被提交给了欧洲计算机制造商协会(ECMA,European Computer Manufacturers Association)。该协会指定 39 号技术委员会(TC39,Technical Committee #39)负责“标准化一种通用、跨平台、供应商中立的脚本语言的语法和语义”(http://www.ecma international.org/memento/TC39.htm)。TC39 由来自 Netscape、Sun、微软、Borland 及其他关注脚本语言 发展的公司的程序员组成,他们经过数月的努力完成了 ECMA-262——定义一种名为 ECMAScript(发 音为“ek-ma-script”)的新脚本语言的标准。

第二年,ISO/IEC(International Organization for Standardization and International Electrotechnical Commission,国标标准化组织和国际电工委员会)也采用了 ECMAScript 作为标准(即 ISO/IEC-16262)。自此以后,浏览器开发商就开始致力于将 ECMAScript 作为各自 JavaScript 实现的基础,也在不同程度上取得了成功

1.2 JavaScript 实现

虽然 JavaScript 和 ECMAScript 通常都被人们用来表达 相同的含义,但 JavaScript 的含义却比 ECMA-262 中规定的 要多得多。没错,一个完整的 JavaScript 实现应该由下列三 个不同的部分组成。

  1. 核心(ECMAScript)
  2. 文档对象模型(DOM)
  3. 浏览器对象模型(BOM)

1.2.1 ECMAScript

由 ECMA-262 定义的 ECMAScript 与 Web 浏览器没有依赖关系。实际上,这门语言本身并不包含输 入和输出定义。ECMA-262 定义的只是这门语言的基础,而在此基础之上可以构建更完善的脚本语言。 我们常见的 Web 浏览器只是 ECMAScript 实现可能的宿主环境之一。宿主环境不仅提供基本的 ECMAScript 实现,同时也会提供该语言的扩展,以便语言与环境之间对接交互。而这些扩展——如 DOM,则利用 ECMAScript 的核心类型和语法提供更多更具体的功能,以便实现针对环境的操作。其他 宿主环境包括 Node(一种服务端 JavaScript 平台)和 Adobe Flash。

既然 ECMA-262 标准没有参照 Web 浏览器,那它都规定了些什么内容呢?大致说来,它规定了这 门语言的下列组成部分:

  1. 语法
  2. 类型
  3. 语句
  4. 关键字
  5. 保留字
  6. 操作符
  7. 对象

ECMAScript 就是对实现该标准规定的各个方面内容的语言的描述。JavaScript 实现了 ECMAScript, Adobe ActionScript 同样也实现了 ECMAScript。

  1. ECMAScript 的版本

ECMAScript 的不同版本又称为版次,以第 x 版表示(意即描述特定实现的 ECMA-262 规范的第 x 个版本)。ECMA-262 的最近一版是第 5 版,发布于 2009 年。而 ECMA-262 的第 1 版本质上与 Netscape 的 JavaScript 1.1 相同——只不过删除了所有针对浏览器的代码并作了一些较小的改动:ECMA-262 要求 支持 Unicode 标准(从而支持多语言开发),而且对象也变成了平台无关的(Netscape JavaScript 1.1 的对 象在不同平台中的实现不一样,例如 Date 对象)。这也是 JavaScript 1.1 和 1.2 与 ECMA-262 第 1 版不一 致的主要原因。 ECMA-262 第 2 版主要是编辑加工的结果。这一版中内容的更新是为了与 ISO/IEC-16262 保持严格 一致,没有作任何新增、修改或删节处理。因此,一般不使用第 2 版来衡量 ECMAScript 实现的兼容性。

ECMA-262 第 3 版才是对该标准第一次真正的修改。修改的内容涉及字符串处理、错误定义和数 值输出。这一版还新增了对正则表达式、新控制语句、try-catch 异常处理的支持,并围绕标准的 国际化做出了一些小的修改。从各方面综合来看,第 3 版标志着 ECMAScript 成为了一门真正的编程 语言。

ECMA-262 第 4 版对这门语言进行了一次全面的检核修订。由于 JavaScript 在 Web 上日益流行,开 发人员纷纷建议修订 ECMAScript,以使其能够满足不断增长的 Web 开发需求。作为回应,ECMA TC39 重新召集相关人员共同谋划这门语言的未来。结果,出台后的标准几乎在第 3 版基础上完全定义了一门 新语言。第 4 版不仅包含了强类型变量、新语句和新数据结构、真正的类和经典继承,还定义了与数据 交互的新方式。

与此同时,TC39 下属的一个小组也提出了一个名为 ECMAScript 3.1 的替代性建议,该建议只对这 门语言进行了较少的改进。这个小组认为第 4 版给这门语言带来的跨越太大了。因此,该小组建议对这门语言进行小幅修订,能够在现有 JavaScript 引擎基础上实现。最终,ES3.1 附属委员会获得的支持超过 了 TC39,ECMA-262 第 4 版在正式发布前被放弃。

ECMAScript 3.1 成为 ECMA-262 第 5 版,并于 2009 年 12 月 3 日正式发布。第 5 版力求澄清第 3 版中已知的歧义并增添了新的功能。新功能包括原生 JSON 对象(用于解析和序列化 JSON 数据)、继 承的方法和高级属性定义,另外还包含一种严格模式,对 ECMAScript 引擎解释和执行代码进行了补充 说明。

  1. 什么是 ECMAScript 兼容

ECMA-262 给出了 ECMAScript 兼容的定义。要想成为 ECMAScript 的实现,则该实现必须做到:

  1. 支持 ECMA-262 描述的所有“类型、值、对象、属性、函数以及程序句法和语义”(ECMA-262 第 1 页);
  2. 支持 Unicode 字符标准。

此外,兼容的实现还可以进行下列扩展。

1)添加 ECMA-262 没有描述的“更多类型、值、对象、属性和函数”。ECMA-262 所说的这些新增 特性,主要是指该标准中没有规定的新对象和对象的新属性。 2)支持 ECMA-262 没有定义的“程序和正则表达式语法”。(也就是说,可以修改和扩展内置的正 则表达式语法。)

上述要求为兼容实现的开发人员基于 ECMAScript 开发一门新语言提供了广阔的空间和极大的灵活 性,这也从另一个侧面说明了 ECMAScript 受开发人员欢迎的原因

3. Web 浏览器对 ECMAScript 的支持

1996 年,Netscape Navigator 3 捆绑发布了 JavaScript 1.1。而相同的 JavaScript 1.1 设计规范随后作为 对新标准(ECMA-262)的建议被提交给 Ecma。伴随着 JavaScript 的迅速走红,Netscape 豪情满怀地着 手开发 JavaScript 1.2。然而,问题是 Ecma 当时还没有接受 Netscape 的建议。

Netscape Navigator 3 发布后不久,微软也推出了 Internet Explorer 3。微软在 IE 的这一版中捆绑了 JScript 1.0,很多人都认为 JScript 1.0 与 JavaScript 1.1 应该是一样的。但是,由于没有文档依据,加之不 适当的特性模仿,JScript 1.0 还是很难与 JavaScript 1.1 相提并论。

1997 年,内置 JavaScript 1.2 的 Netscape Navigator 4 发布;而到这一年年底,ECMA-262 第 1 版

全文共10310字,剩余内容已隐藏,支付完成后下载完整资料


资料编号:[1168]

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。