外文翻译javaScript的学习

上传人:ni****g 文档编号:506423890 上传时间:2023-05-03 格式:DOC 页数:10 大小:68KB
返回 下载 相关 举报
外文翻译javaScript的学习_第1页
第1页 / 共10页
外文翻译javaScript的学习_第2页
第2页 / 共10页
外文翻译javaScript的学习_第3页
第3页 / 共10页
外文翻译javaScript的学习_第4页
第4页 / 共10页
外文翻译javaScript的学习_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《外文翻译javaScript的学习》由会员分享,可在线阅读,更多相关《外文翻译javaScript的学习(10页珍藏版)》请在金锄头文库上搜索。

1、外文原文来源: Mastering Ajax 14 Aug 2007 From OReilly Media Inc.2JavaScript RefresherJavaScript is an essential piece of the Ajax package. JavaScript serves as the intermediary betweenthe browser (the client) and the server so that a web page can be dynamically updated withoutrefreshing the entire page.Ja

2、vaScript was developed by Brendan Eich and introduced in the 1995 release of Netscape 2.0.Because JavaScript offered a means to add interactivity to HTML pages, it quickly became popularand widely used. Different versions were developed both by Netscape and other browser manufacturers,but eventually

3、 the JavaScript language was standardized by the European ComputerManufacturers Association (ECMA) as ECMAScript.The ECMAScript standard defines the core of the JavaScript language. Most browsers today supportthe third edition of the ECMA-262 standard.This chapter provides a review of core JavaScrip

4、t (ECMAScript), JavaScript objects, the DocumentObject Model (DOM), and event handling for readers who have some familiarity and experiencewith JavaScript and with basic programming constructs (variables, operators, functions). If yourenew to programming and/or JavaScript, refer to books such as Beg

5、inning JavaScript, Second Edition(Indianapolis: Wiley Publishing, 2004) and Professional JavaScript for Web Developers (Indianapolis:Wiley Publishing, 2005) for more comprehensive information about JavaScript.In this chapter, you learn about these topics: Core JavaScript (variables, operators, state

6、ments, functions) Object-oriented JavaScript (built-in objects, the Browser Object Model, user-defined objects) The Document Object Model (DOM) JavaScript and eventsCore JavaScriptCore JavaScript (ECMAScript) provides everything you need to accomplish basic programming tasks:variables, operators tha

7、t act on the variables, statements, and functions that provide reuseable blocks ofcode to accomplish a task. Objects are also part of ECMAScript, and they are discussed later in this chapterin the section, “Object-Oriented JavaScript.”SyntaxThe ECMAScript standard specifies JavaScripts basic syntax

8、rules. Using correct syntax is crucial. Ifyour code has syntax errors, the browsers JavaScript interpreter stops processing your code until theerror is corrected.A few guidelines can help you follow good programming practices and avoid syntax errors: JavaScript is case-sensitive Pay extra attention

9、when using capital letters in the names ofvariables, functions, and objects. A variable named myVar is not the same as one named myvar. Semicolons are optional Even though semicolons are not required at the end of every codestatement, its good practice to include them in your code to delineate where

10、 the line of codeends. They make the code easier to read, easier to debug, and they help decrease the number oferrors generated when the browser reads your code. Let the code wrap Dont insert line returns in the middle of a line of code. A line return characterin the middle of a code statement is on

11、e of the most common errors in JavaScript, and linereturns will make your code non-functional. Add comments The syntax for JavaScript comments is / for a single-line comment and /*and */ for opening and closing multiline comments. Commenting your code makes it mucheasier for you or anyone else to un

12、derstand your code when its being updated or debugged.Remember, the person updating or debugging just might be you.VariablesA variable is a temporary storage container for data. JavaScript variables can be declared using the varkeyword. For example, the following declares a new variable named myColo

13、r:var myColor;This variable doesnt contain any information yet. If you included this variable in an alert message, suchas the following, its value would be undefined, as shown in Figure 2-1:alert (“myColor = “ + myColor);Figure 2-1: Undefined value.You dont have to declare a variable as a separate s

14、tep. Instead, you can initialize a variabledeclare itand assign a value to it at the same time, as shown here:var myColor = “green”;Variable names must start with a letter, an underscore (_), or a dollar sign ($). Camel notation is commonlyused for variable names, although no specific notation is re

15、quired. In camel notation, the firstword is lowercase, and additional words start with a capital letter, as shown here:var myFavoriteNumber;Primitive DatatypesEvery JavaScript variable has a datatype that indicates the kind of data the variable contains. Primitivedatatypes store data directly in a v

16、ariable. There are five types of primitive datatypes: Number String Boolean Undefined NullThe Number type includes both integers and floating-point numbers. The String type includes any groupof one or more characters. A string is distinguished from a number by enclosing it in quotation marks.For example, “5” is a

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 医学/心理学 > 基础医学

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号