Nicht aus der Schweiz? Besuchen Sie lehmanns.de
JavaScript for Absolute Beginners - Terry McNavage

JavaScript for Absolute Beginners (eBook)

(Autor)

eBook Download: PDF
2011 | 1st ed.
504 Seiten
Apress (Verlag)
978-1-4302-7218-2 (ISBN)
Systemvoraussetzungen
39,99 inkl. MwSt
(CHF 38,95)
Der eBook-Verkauf erfolgt durch die Lehmanns Media GmbH (Berlin) zum Preis in Euro inkl. MwSt.
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

If you are new to both JavaScript and programming, this hands-on book is for you. Rather than staring blankly at gobbledygook, you'll explore JavaScript by entering and running hundreds of code samples in Firebug, a free JavaScript debugger. Then in the last two chapters, you'll leave the safety of Firebug and hand-code an uber cool JavaScript application in your preferred text editor.

Written in a friendly, engaging narrative style, this innovative JavaScript tutorial covers the following essentials:

  • Core JavaScript syntax, such as value types, operators, expressions, and statements provided by ECMAScript.
  • Features for manipulating XHTML, CSS, and events provided by DOM.
  • Object-oriented JavaScript, including prototypal and classical inheritance, deep copy, and mixins.
  • Closure, lazy loading, advance conditional loading, chaining, currying, memoization, modules, callbacks, recursion, and other powerful function techniques.
  • Encoding data with JSON or XML.
  • Remote scripting with JSON-P or XMLHttpRequest
  • Drag-and-drop, animated scrollers, skin swappers, and other cool behaviors.
  • Optimizations to ensure your scripts run snappy.
  • Formatting and naming conventions to prevent you from looking like a greenhorn.
  • New ECMAScript 5, DOM 3, and HTML 5 features such as Object.create(), Function.prototype.bind(), strict mode, querySelector(), querySelectorAll(), and getElementsByClassName().

As you can see, due to its fresh approach, this book is by no means watered down. Therefore, over the course of your journey, you will go from JavaScript beginner to wizard, acquiring the skills recruiters desire.



Terry McNavage has been programming with JavaScript for 14 years and is the author of 'JavaScript for Absolute Beginners' (Apress, December 2010). In addition, Terry is an elite runner, typically running 100 or more miles per week, and a bit of a food geek. Like Brendan Eich, JavaScript's creator, Terry is from Pittsburgh, Pennsylvania. So he's hoping the Pirates raise the Jolly Roger more often than not in 2012 rather than notch their 20th losing season in a row.
If you are new to both JavaScript and programming, this hands-on book is for you. Rather than staring blankly at gobbledygook, you'll explore JavaScript by entering and running hundreds of code samples in Firebug, a free JavaScript debugger. Then in the last two chapters, you'll leave the safety of Firebug and hand-code an uber cool JavaScript application in your preferred text editor.Written in a friendly, engaging narrative style, this innovative JavaScript tutorial covers the following essentials: Core JavaScript syntax, such as value types, operators, expressions, and statements provided by ECMAScript. Features for manipulating XHTML, CSS, and events provided by DOM. Object-oriented JavaScript, including prototypal and classical inheritance, deep copy, and mixins. Closure, lazy loading, advance conditional loading, chaining, currying, memoization, modules, callbacks, recursion, and other powerful function techniques. Encoding data with JSON or XML. Remote scripting with JSON-P or XMLHttpRequest Drag-and-drop, animated scrollers, skin swappers, and other cool behaviors. Optimizations to ensure your scripts run snappy. Formatting and naming conventions to prevent you from looking like a greenhorn. New ECMAScript 5, DOM 3, and HTML 5 features such as Object.create(), Function.prototype.bind(), strict mode, querySelector(), querySelectorAll(), and getElementsByClassName(). As you can see, due to its fresh approach, this book is by no means watered down. Therefore, over the course of your journey, you will go from JavaScript beginner to wizard, acquiring the skills recruiters desire.

Terry McNavage has been programming with JavaScript for 14 years and is the author of "JavaScript for Absolute Beginners" (Apress, December 2010). In addition, Terry is an elite runner, typically running 100 or more miles per week, and a bit of a food geek. Like Brendan Eich, JavaScript's creator, Terry is from Pittsburgh, Pennsylvania. So he's hoping the Pirates raise the Jolly Roger more often than not in 2012 rather than notch their 20th losing season in a row.

Cover 1
Title Page 2
Copyright Page 3
Dedication Page 4
Table of Contents 6
About the Author 14
About the Technical Reviewers 15
Acknowledgments 16
Preface 17
Opening Firebug 19
Enabling Firebug 20
Command Line 20
Command Editor 21
CHAPTER 1 Representing Data with Values 25
What Are Value Types? 25
Creating a String Literal 26
Commenting Code 26
Gluing Strings Together with the + Operator 27
Creating a Number Literal 28
Creating a Boolean Literal 29
Naming a Value with an Identifier 30
Can I Name a Variable Anything I Want? 30
Some Valid Identifiers Are Already Taken 31
Creating an Object Literal 33
Naming Members with Identifiers 37
Creating an Array Literal 38
Creating a Function Literal 43
Summary 47
CHAPTER 2 Type Conversion 48
String Members 48
Determining the Number of Characters 53
Decoding or Encoding Characters 55
Converting Case 56
Locating a Substring 58
Clipping a Substring 59
Replacing a Substring 60
Splitting a String into an Array of Smaller Strings 62
Searching with Regular Expressions 66
Explicitly Creating Wrappers 66
Converting a Value to Another Type 67
Converting a Value to a Number 69
Converting a Value to a String 73
Methods for Converting a Number to a String 74
Putting Off Learning RegExp Syntax 76
Summary 79
CHAPTER 3 Operators 80
Introducing Operator Precedence and Associativity 80
Using JavaScript Operators 83
Combining Math and Assignment Operations 84
Incrementing or Decrementing Values 89
Testing for Equality 91
Testing for Inequality 94
Comparing Objects, Arrays, and Functions 95
Determining Whether One Number or String Is Greater Than 98
Determining Whether One Number or String Is Less Than Another 100
Greater Than or Equal to, Less Than or Equal to 102
Creating More Complex Comparisons 104
Saying or With || 106
Saying “and” with & &
Chaining || Expressions 108
Chaining & &
Chaining || and & &
Conditionally Returning One of Two Values 113
Making Two Expressions Count as One 116
Deleting a Member, Element, or Variable 117
Summary 118
CHAPTER 4 Controlling Flow 119
Writing an if Condition 120
Appending an else Clause 122
To Wrap or Not to Wrap 123
Coding Several Paths with the else if Idiom 124
Controlling Flow with Conditional Expressions 128
Taking One of Several Paths with a Switch 129
Writing a while Loop 138
Aborting an Iteration but Not the Loop 140
Replacing Break with Return in a Function 142
Writing a do while loop 144
Writing a for Loop 147
Enumerating Members with a for in Loop 149
Snappier Conditionals 151
Snappier Loops 158
Summary 166
CHAPTER 5 Member Inheritance 167
Creating Objects with a Constructor 167
Classical Inheritance 171
Determining Which Type or Types an Object Is an Instance Of 179
Inherited Members Are Shared Not Copied 180
Modifying New and Past Instances of a Type 182
Sharing a Prototype but Forgoing the Chain 185
Adding an Empty Chain Link 188
Stealing a Constructor 191
Prototypal Inheritance 193
Cloning Members 196
Mixins 198
Summary 201
CHAPTER 6 Functions and Arrays 202
Why Use Functions? 202
Functions Are Values 204
Function Members 205
Conditional Advance Loading 206
Writing Object.defineProperty() 207
Writing Object.defineProperties() 209
Writing Object.create() 209
Using the new Functions 210
Lazy Loading 216
Recursion 219
Borrowing Methods with apply() or call() 222
Overriding toString() 222
Testing for an Array 225
Rewriting cloneMembers() 227
Currying 229
Chaining Methods 234
Closure and Returning Functions 238
Passing a Configuration Object 244
Callback Functions 245
Memoization 247
Global Abatement with Modules 248
Arrays 251
Plucking Elements from an Array 251
Adding Elements to an Array 255
Gluing Two Arrays Together 257
Reversing the Elements in an Array 259
Sorting the Elements in an Array 260
Creating a String from an Array 265
Taking a Slice of an Array 266
Converting a Read-only Array-like Object to an Array 268
Inserting or Deleting Elements from an Array 271
Summary 275
CHAPTER 7 Traversing and Modifying the DOM Tree 276
DOM Tree 276
Is Every Node the Same? 277
Interfaces Are Sensibly Named 278
Querying the DOM Tree 278
Same Jargon as for a Family Tree 281
Traversing the DOM Tree 281
Descending with childNodes 281
Ascending with parentNode 283
Muddying the Waters with Whitespace 284
Coding Cascade Style 285
Moving Laterally 289
Converting a NodeList to an Array 292
Converting a NodeList to an Array for Internet Explorer 294
Traversing the DOM without childNodes 296
Finding an Element by ID 298
Finding Elements by Their Tag Names 299
Finding Elements by Class 300
Querying Attributes Like a Member 303
Querying Attributes with Methods 303
Querying Attr Nodes 306
Enumerating Attributes for an Element 307
Creating Element or Text Nodes 310
Deleting Content 313
Copying Content 314
Creating Elements with a Helper Function 315
Reordering Nested Lists 318
Where Did the Formatting Text Nodes Go? 323
Summary 326
CHAPTER 8 Scripting CSS 327
DOM Interfaces for Working with CSS 327
Clarifying Some CSS Jargon 328
How Does JavaScript Represent a Rule? 328
Two Other Declaration Blobs 330
Downloading the Sample Files 330
Querying a Style Attribute 333
Scripting Classes 338
Scripting Rules 340
Scripting Imported Style Sheets 346
Adding or Deleting a Rule 347
Adding a Rule to a Style Sheet 349
Deleting a Rule from a Style Sheet 352
Querying Overall Styles from the Cascade 354
Enabling and Disabling Style Sheets 358
Including or Importing Style Sheets 359
Embedding a Style Sheet 364
Summary 365
CHAPTER 9 Listening for Events 366
Working with the Event Object 366
Downloading Project Files 367
Advance Conditional Loading 371
Telling JavaScript to Stop Listening for an Event 372
Preventing Default Actions from Taking Place 373
Preventing an Event from Traversing the DOM Tree 374
Writing Helper Functions 376
Crawling the DOM Tree 376
Finding an Element by Class 377
Testing for getElementsByClassName() 379
Querying the Cascade 381
Sliding Sprites 384
Preparing the Ground 384
Moving the Sprites 387
Snappier Sprites 390
Drag-and-Drop Behavior 395
Writing the Mousedown Event Listener 395
Writing the Mousemove Event Listener 399
Writing the Mouseup Event Listener 400
The doZ() Helper Function 402
Prepping the Drag 403
Swapping Skins by Key 411
Initiating Behaviors When the DOM Tree Is Available 415
Fighting Global Evil 415
Summary 416
CHAPTER 10 Scripting BOM 417
Downloading the Project Files 417
Remembering Visitor Data with Cookies 419
Getting the User’s Preference 419
Setting the User’s Skin Preference 421
Setting the User’s Preference 422
Animating with Timers 425
Preparing the Scrollers 425
Adding the Press Event Listener 428
Writing the Animation Function 430
Using the Gallery 432
Animating the Gallery 433
Swapping Sprites by ID or Class 438
Writing Dynamic Pages Using Ajax 441
Testing XMLHttpRequest from Your Local File System 442
Creating Tree Branches with createElem() 442
Asynchronously Requesting Data 444
Parsing an HTML Response 446
Parsing an XML Response 450
Parsing Simple XML 455
Parsing JSON 459
JSON in a Nutshell 460
Padding JSON 465
Converting function declarations to expressions 469
Summary 478
Yielding with Timers 469
Index 479

Erscheint lt. Verlag 23.8.2011
Zusatzinfo 504 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Theorie / Studium
Mathematik / Informatik Informatik Web / Internet
Schlagworte CSS • Dom • HTML • Java • JavaScript • JSON • techniques • XHTML • XML
ISBN-10 1-4302-7218-X / 143027218X
ISBN-13 978-1-4302-7218-2 / 9781430272182
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 6,6 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Discover tactics to decrease churn and expand revenue

von Jeff Mar; Peter Armaly

eBook Download (2024)
Packt Publishing (Verlag)
CHF 24,60