copyright © 2008 pearson education, inc. publishing as pearson addison-wesley chapter 4 the basics...

23
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth edition By Robert W. Sebesta

Upload: danielle-johnston

Post on 26-Mar-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 4The Basics of Javascript

Programming the World Wide Web Fourth edition

By Robert W. Sebesta

Page 2: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-2Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.1 JavaScript reserved words

Page 3: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-3Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.1 Primitives and objects

Page 4: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-4Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.2 Precedence and associativity of the numeric operators

Page 5: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-5Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.3 Properties of Number

Page 6: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-6Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.4 String methods

Page 7: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-7Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.5 Methods for the Date object

Page 8: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-8Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.2 An example of the output of document.write

Page 9: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-9Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.3 An example of the output of alert

Page 10: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-10Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.4 An example of the outputof confirm

Page 11: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-11Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.5 An example of the output of prompt

Page 12: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-12Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.6 Relational operators

Page 13: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-13Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.7 Operator precedence and associativity

Page 14: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-14Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.6 Dialog box from borders2.js

Page 15: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-15Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.7 Display of borders2.js

Page 16: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-16Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.8 Display of date.js

Page 17: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-17Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.9 Display of nested_arrays.js

Page 18: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-18Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.10 Display of params.js

Page 19: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-19Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.11 Display of medians.js

Page 20: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-20Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table 4.8 Predefined character classes

Page 21: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-21Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.12 Display of forms_check.js

Page 22: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-22Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.13 Display of debugdemo.js with Internet Explorer 7

Page 23: Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth

4-23Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Figure 4.14 Display of the FireFox 2 error console