وبلاگ بلیان

Object-oriented JavaScript : create scalable, reusable high-quality JavaScript applications, and libraries

معرفی کتاب «Object-oriented JavaScript : create scalable, reusable high-quality JavaScript applications, and libraries» نوشتهٔ Stoyan Stefanov، منتشرشده توسط نشر Packt Publishing Limited در سال 2008. این کتاب در 5 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «Object-oriented JavaScript : create scalable, reusable high-quality JavaScript applications, and libraries» در دستهٔ بدون دسته‌بندی قرار دارد.

Once listed in the "nice to have" sections of job postings, these days the knowledge of JavaScript is a deciding factor when it comes to hiring web developers. And rightly so. Where in the past we used to have the occasional few lines of JavaScript embedded in a web page, now we have advanced libraries and extensible architectures, powering the "fat-client", AJAX-type rich internet applications. JavaScript is the language of the browser, but it's also heavily employed in many other environments: server-side programming, desktop applications, application extensions and widgets. It's a pretty good deal: you learn one language and then code all kinds of different applications. While this book has one chapter specifically dedicated to the web browser environment including DOM, events, and AJAX tutorials, the rest is applicable to all the other environments too. This book treats JavaScript as a serious object-oriented language, showing you how to build robust, maintainable, and powerful libraries and applications. Along the way, we cover many of the recent innovations such as AJAX, JSON, and interesting design and coding patterns. After reading this book, you'll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn't know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication. What you will learn from this book? * Learn to think in JavaScript, the language of the web browser * The basics of object-oriented programming, and how they apply to JavaScript * Set up and use your training environment (Firebug) * Master data types, operators, and flow control statements * Understand functions: usage patterns, variable scope, and built-in functions * Closures demystified * Create and use objects * Understand and use prototypes * Reuse code with common patterns for inheritance * Understand and work with the BOM (Browser Object Model) * The DOM (Document Object Model) - accessing, modifying, adding, and deleting nodes * Build responsive web pages with AJAX * JSON (JavaScript Object Notation) * Listen and respond to browser events * Apply design patterns to solve common problems * Adopt coding patterns that unleash the unique power of the language * Make your programs cleaner, faster, and compatible with other programs and libraries * Achieve missing object-oriented features in JavaScript such as private properties and methods Who is this book written for? The book requires no prior knowledge of JavaScript and works from the ground up to give you a thorough grounding in this powerful language. If you do already know some JavaScript, you will find plenty of eye-openers as you discover just what the language can do. This book takes a do-it-yourself approach when it comes to writing code, because the best way to really learn a programming language is by writing code. You are encouraged to type code into Firebug's console, see how it works and then tweak it and play around with it. There are practice questions at the end of each chapter to help review what you have learned. Object-Oriented JavaScript 1 Table of Contents 10 Preface 18 Chapter 1: Introduction 26 A Bit of History 27 The Winds of Change 28 The Present 28 The Future 29 Object-Oriented Programming 29 Objects 30 Classes 30 Encapsulation 31 Aggregation 32 Inheritance 32 Polymorphism 33 OOP Summary 33 Setting up Your Training Environment 34 Getting the Tools You Need 34 Using the Firebug Console 35 Summary 37 Chapter 2: Primitive Data Types, Arrays, Loops, and Conditions 38 Variables 38 Variables are Case Sensitive 39 Operators 40 Primitive Data Types 43 Finding out the Value Type 鈥攖he typeof Operator 44 Numbers 44 Octal and Hexadecimal Numbers 45 Exponent Literals 46 Infinity 47 NaN 48 Strings 49 String Conversions 50 Special Strings 51 Booleans 52 Logical Operators 53 Operator Precedence 55 Lazy Evaluation 56 Comparison 57 Undefined and null 58 Primitive Data Types Recap 60 Arrays 61 Adding/Updating Array Elements 62 Deleting Elements 63 Arrays of arrays 63 Conditions and Loops 65 Code Blocks 65 if Conditions 66 Checking if a Variable Exists 67 Alternative if Syntax 69 Switch 69 Loops 71 While Loops 71 Do-while loops 72 For Loops 72 For-in Loops 75 Comments 76 Summary 76 Exercises 77 Chapter 3: Functions 78 What is a Function? 79 Calling a Function 79 Parameters 79 Pre-defined Functions 81 parseInt() 82 parseFloat() 83 isNaN() 84 isFinite() 85 Encode/Decode URIs 85 eval() 86 A Bonus鈥攖he alert() Function 86 Scope of Variables 87 Functions are Data 89 Anonymous Functions 90 Callback Functions 90 Callback Examples 91 Self-invoking Functions 93 Inner (Private) Functions 94 Functions that Return Functions 95 Function, Rewrite Thyself! 95 Closures 97 Scope Chain 97 Lexical Scope 98 Breaking the Chain with a Closure 99 Closure #1 101 Closure #2 102 A Definition and Closure #3 102 Closures in a Loop 103 Getter/Setter 105 Iterator 106 Summary 107 Exercises 108 Chapter 4: Objects 110 From Arrays to Objects 110 Elements, Properties, Methods 112 Hashes, Associative Arrays 112 Accessing Object's Properties 113 Calling an Object's Methods 114 Altering Properties/Methods 115 Using this Value 116 Constructor Functions 116 The Global Object 117 constructor Property 119 instanceof Operator 119 Functions that Return Objects 120 Passing Objects 121 Comparing Objects 122 Objects in the Firebug Console 123 Built-in Objects 124 Object 125 Array 126 Interesting Array Methods 129 Function 130 Properties of the Function Objects 132 Methods of the Function Objects 133 The arguments Object Revisited 135 Boolean 136 Number 138 String 139 Interesting Methods of the String Objects 141 Math 144 Date 146 Methods to Work with Date Objects 149 RegExp 151 Properties of the RegExp Objects 152 Methods of the RegExp Objects 153 String Methods that Accept Regular Expressions as Parameters 153 search() and match() 154 replace() 154 Replace callbacks 155 split() 156 Passing a String When a regexp is Expected 157 Summary 161 Exercises 162 Chapter 5: Prototype 166 The prototype Property 166 Adding Methods and Properties Using the Prototype 167 Using the Prototype's Methods and Properties 168 Own Properties versus prototype Properties 169 Overwriting Prototype's Property with Own Property 171 Enumerating Properties 172 isPrototypeOf() 174 The Secret __proto__ Link 175 Augmenting Built-in Objects 177 Augmenting Built-in Objects鈥擠iscussion 178 Some Prototype gotchas 179 Summary 182 Exercises 182 Chapter 6: Inheritance 184 Prototype Chaining 184 Prototype Chaining Example 185 Moving Shared Properties to the Prototype 188 Inheriting the Prototype Only 190 A Temporary Constructor鈥攏ew F() 192 Uber鈥擜ccess to the Parent from a Child Object 193 Isolating the Inheritance Part into a Function 195 Copying Properties 196 Heads-up When Copying by Reference 197 Objects Inherit from Objects 200 Deep Copy 201 object() 203 Using a Mix of Prototypal Inheritance and Copying Properties 204 Multiple Inheritance 205 Mixins 207 Parasitic Inheritance 207 Borrowing a Constructor 208 Borrow a Constructor and Copy its Prototype 210 Summary 211 Case Study: Drawing Shapes 215 Analysis 215 Implementation 216 Testing 220 Exercises 221 Chapter 7: The Browser Environment 222 Including JavaScript in an HTML Page 222 BOM and DOM鈥擜n Overview 223 BOM 224 The window Object Revisited 224 window.navigator 225 Firebug as a Cheat Sheet 225 window.location 226 window.history 227 window.frames 228 window.screen 229 window.open()/close() 230 window.moveTo(), window.resizeTo() 231 window.alert(), window.prompt(), window.confirm() 231 window.setTimeout(), window.setInterval() 233 window.document 234 DOM 235 Core DOM and HTML DOM 237 Accessing DOM Nodes 239 The document Node 239 documentElement 241 Child Nodes 241 Attributes 242 Accessing the Content Inside a Tag 243 DOM Access Shortcuts 244 Siblings, Body, First, and Last Child 246 Walk the DOM 247 Modifying DOM Nodes 248 Modifying Styles 249 Fun with Forms 250 Creating New Nodes 251 DOM-only Method 252 cloneNode() 253 insertBefore() 254 Removing Nodes 254 HTML-Only DOM Objects 256 Primitive Ways to Access the Document 256 document.write() 258 Cookies, Title, Referrer, Domain 258 Events 260 Inline HTML Attributes 260 Element Properties 261 DOM Event Listeners 261 Capturing and Bubbling 263 Stop Propagation 265 Prevent Default Behavior 267 Cross-Browser Event Listeners 267 Types of Events 269 XMLHttpRequest 270 Send the Request 270 Process the Response 271 Creating XMLHttpRequest Objects in IE prior to version 7 272 A is for Asynchronous 273 X is for XML 274 An Example 274 Summary 277 Exercises 278 Chapter 8: Coding and Design Patterns 282 Coding Patterns 283 Separating Behavior 283 Content 283 Presentation 284 Behavior 284 Example of Separating Behavior 285 Namespaces 285 An Object as a Namespace 286 Namespaced Constructors 286 A namespace() Method 287 Init-Time Branching 288 Lazy Definition 289 Configuration Object 290 Private Properties and Methods 292 Privileged Methods 293 Private Functions as Public Methods 293 Self-Executing Functions 294 Chaining 295 JSON 296 Design Patterns 297 Singleton 298 Singleton 2 298 Global Variable 299 Property of the Constructor 299 In a Private Property 300 Factory 300 Decorator 302 Decorating a Christmas Tree 302 Observer 304 Summary 307 Appendix A: Reserved Words 308 Keywords 308 Future Reserved Words 309 Appendix B: Built-in Functions 312 Appendix C: Built-in Objects 316 Object 316 Members of the Object Constructor 317 Members of the Objects Created by the Object Constructor 317 Array 319 Members of the Array Objects 320 Function 322 Members of the Function Objects 323 Boolean 323 Number 324 Members of the Number Constructor 325 Members of the Number Objects 326 String 327 Members of the String Constructor 327 Members of the String Objects 328 Date 330 Members of the Date Constructor 331 Members of the Date Objects 331 Math 335 Members of the Math Object 336 RegExp 337 Members of RegExp Objects 338 Error Objects 339 Members of the Error Objects 340 Appendix D: Regular Expressions 342 Index 348

In Detail

Once listed in the "nice to have" sections of job postings, these days the knowledge of JavaScript is a deciding factor when it comes to hiring web developers. And rightly so. Where in the past we used to have the occasional few lines of JavaScript embedded in a web page, now we have advanced libraries and extensible architectures, powering the "fat-client", AJAX-type rich internet applications.

JavaScript is the language of the browser, but it's also heavily employed in many other environments: server-side programming, desktop applications, application extensions and widgets. It's a pretty good deal: you learn one language and then code all kinds of different applications. While this book has one chapter specifically dedicated to the web browser environment including DOM, events, and AJAX tutorials, the rest is applicable to all the other environments too. 

This book treats JavaScript as a serious object-oriented language, showing you how to build robust, maintainable, and powerful libraries and applications. Along the way, we cover many of the recent innovations such as AJAX, JSON, and interesting design and coding patterns. After reading this book, you'll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn't know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication.

Create scalable and reusable high-quality JavaScript applications and libraries using the concepts of object-oriented programming

Who this book is for

The book requires no prior knowledge of JavaScript and works from the ground up to give you a thorough grounding in this powerful language. If you do already know some JavaScript, you will find plenty of eye-openers as you discover just what the language can do.

This book takes a do-it-yourself approach when it comes to writing code, because the best way to really learn a programming language is by writing code. You are encouraged to type code into Firebug's console, see how it works and then tweak it and play around with it. There are practice questions at the end of each chapter to help review what you have learned.

Annotation Once listed in the "nice to have" sections of job postings, these days the knowledge of JavaScript is a deciding factor when it comes to hiring web developers. And rightly so. Where in the past we used to have the occasional few lines of JavaScript embedded in a web page, now we have advanced libraries and extensible architectures, powering the "fat-client", AJAX-type rich internet applications. JavaScript is the language of the browser, but it's also heavily employed in many other environments: server-side programming, desktop applications, application extensions and widgets. It's a pretty good deal: you learn one language and then code all kinds of different applications. While this book has one chapter specifically dedicated to the web browser environment including DOM, events, and AJAX tutorials, the rest is applicable to all the other environments too. This book treats JavaScript as a serious object-oriented language, showing you how to build robust, maintainable, and powerful libraries and applications. Along the way, we cover many of the recent innovations such as AJAX, JSON, and interesting design and coding patterns. After reading this book, you'll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn't know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication This book treats JavaScript as a serious object-oriented language, showing you how to build robust, maintainable, and powerful libraries and applications. Along the way, we cover many of the recent innovations such as AJAX, JSON, and interesting design and coding patterns. After reading this book, you'll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn't know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication. Create scalable and reusable high-quality JavaScript applications and libraries using the concepts of object-oriented programming. Create scalable and reusable high-quality JavaScript applications and libraries using the concepts of object-oriented programming. This book is for the beginning to intermediate web developer who wants to solve web development problems with smart JavaScript. It does not assume any prior knowledge of JavaScript programming; however even if you already know some JavaScript, there will be plenty for you to learn here.
دانلود کتاب Object-oriented JavaScript : create scalable, reusable high-quality JavaScript applications, and libraries