Javascript Specialist Academic Student Guide Web Development Series ECL02-CEJSRF-PR-1109 • Version 1.01 • Rd092811
Total Page:16
File Type:pdf, Size:1020Kb
JavaScript Specialist Academic Student Guide Web Development Series ECL02-CEJSRF-PR-1109 • version 1.01 • rd092811 EVALUATION COPY EVALUATION COPY JavaScript Specialist Academic Student Guide EVALUATION COPY President/Chief Certification Architect James Stanger, Ph.D. Vice President, Operations Todd Hopkins Senior Content Developer Kenneth A. Kozakis Managing Editor Susan M. Lane Editor Sarah Skodak Project Manager/Publisher Tina Strong Customer Service Certification Partners, LLC 1230 W. Washington St., Ste. 111 Tempe, AZ 85281 (602) 275-7700 Copyright © 2011, All rights reserved. EVALUATION COPY JavaScript Specialist Developers Brian Danks, Elliot Cherner, Ashley Craft and Susan M. Lane Contributors Lisa Pease Editor Susan M. Lane Project Manager/Publisher Tina Strong Trademarks Certification Partners is a trademark of Certification Partners, LLC. All product names and services identified throughout this book are trademarks or registered trademarks of their respective companies. They are used throughout this book in editorial fashion only. No such use, or the use of any trade name, is intended to convey endorsement or other affiliation with the book. Copyrights of any screen captures in this book are the property of the software's manufacturer. Disclaimer Certification Partners, LLC, makes a genuine attempt to ensure the accuracy and quality of the content described herein; however, Certification Partners makes no warranty, express or implied, with respect to the quality, reliability, accuracy, or freedom from error of this document or the products it describes. Certification Partners makes no representation or warranty with respect to the contents hereof and specifically disclaims any implied warranties of fitness for any particular purpose. Certification Partners disclaims all liability for any direct, indirect, incidental or consequential, special or exemplary damages resulting from the use of the information in this document or from the use of any products described in this document. Mention of any product or organization does not constitute an endorsement by Certification Partners of that product or corporation. Data used in examples and labs is intended to be fictional even if actual data is used or accessed. Any resemblance to, or use of real persons or organizations should be treated as entirely coincidental. Certification Partners makes every effort to ensure the accuracy of URLs referenced in all its material, but cannot guarantee that all URLs will be available throughout the life of a course. When this course was published, all URLs were checked for accuracy and completeness. However, due to the ever-changing nature of the Internet, some URLs may no longer be available or may have been redirected. Copyright Information This training manual is copyrighted and all rights are reserved by Certification Partners, LLC. No part of this publication may be reproduced, transmitted, stored in a retrieval system, modified, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise without written permission of Certification Partners, 1230 W. Washington Street, Suite 111, Tempe, AZ 85281. EVALUATION COPY Copyright © 2011 by Certification Partners, LLC All Rights Reserved ISBN: 0-7423-2928-3 vi EVALUATION COPY © 2011 Certification Partners, LLC. — All Rights Reserved. Version 1.01 vii Table of Contents Course Description...................................................................................................................... xiv Courseware .................................................................................................................................. xv Course Objectives...................................................................................................................... xviii Classroom Setup ....................................................................................................................... xviii System Requirements ............................................................................................................... xviii Conventions and Graphics Used in This Book .............................................................................. xxi Lesson 1: Introduction to JavaScript........................................................................................... 1-1 Pre-Assessment Questions ................................................................................................................1-2 Introduction to Scripting ...................................................................................................................1-3 JavaScript Characteristics.................................................................................................................1-3 JavaScript and Common Programming Concepts...............................................................................1-5 JavaScript Flavors and Versions........................................................................................................1-6 Server-Side vs. Client-Side Applications.............................................................................................1-9 Annotating Your Code with Comments ............................................................................................ 1-13 Case Study...................................................................................................................................... 1-16 Lesson 1 Review .............................................................................................................................. 1-18 Lesson 2: Working with Variables and Data in JavaScript ............................................................ 2-1 Pre-Assessment Questions ................................................................................................................2-2 Using JavaScript to Communicate with the User ...............................................................................2-3 Using Data More Than Once: Variables ...........................................................................................2-12 JavaScript Expressions ................................................................................................................... 2-17 JavaScript Operators....................................................................................................................... 2-18 Inline Scripting, Simple User Events, and Basic Event Handlers...................................................... 2-26 JavaScript Keywords and Reserved Words....................................................................................... 2-28 Case Study...................................................................................................................................... 2-30 Lesson 2 Review .............................................................................................................................. 2-33 Lesson 3: Functions, Methods and Events in JavaScript.............................................................. 3-1 Pre-Assessment Questions ................................................................................................................3-2 Introduction to Functions..................................................................................................................3-2 Defining a Function...........................................................................................................................3-3 Calling a Function.............................................................................................................................3-6 User Events and JavaScript Event Handlers.................................................................................... 3-16 Methods as Functions ..................................................................................................................... 3-17 Case Study...................................................................................................................................... 3-21 Lesson 3 Review .............................................................................................................................. 3-23 Lesson 4: Controlling Program Flow in JavaScript....................................................................... 4-1 Pre-Assessment Questions ................................................................................................................4-2 Controlling Decisional Program Flow .................................................................................................4-3 The if...else Statement .......................................................................................................................4-3 The while Statement..........................................................................................................................4-8 The do...while Statement ................................................................................................................. 4-11 The for Statement............................................................................................................................ 4-13 The break Statement ....................................................................................................................... 4-16 The continue Statement ................................................................................................................... 4-18 The