Đang chuẩn bị liên kết để tải về tài liệu:
Practical prototype and scipt.aculo.us part 30

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Practical prototype and scipt.aculo.us part 30: The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | CHAPTER 7 ADVANCED JAVASCRIPT FUNCTIONAL PROGRAMMING AND CLASS-BASED OOP 165 var retotal totaler.updateTotal.bind totaler retotal The method runs error free. Function bind is most useful when dealing with event assignment. Switching the context in which an event handler runs is something we ll need to do quite often in the chapters to come. Summary We ve taken a brief glance at two useful models for DOM scripting functional and object-oriented programming. These models in fact go far beyond contrived code patterns they re manifestations of core features of JavaScript. Functional programming is right at home in the event-driven world of browser scripting OOP is a corollary of JavaScript s principles of mutability and scope. You ll be able to appreciate these pillars of JavaScript coding philosophy as we delve into the use cases presented in Part 2. CHAPTER 8 Other Helpful Things Useful Methods on Built-Ins s embarrassing as it is for me to have a chapter devoted to other random stuff I ve decided to write it anyway. This book isn t meant to teach you JavaScript it s meant to be a survey of a framework that acts as JavaScript s standard library. Prototype sticks utility methods in appropriate nooks and crannies some of which are simply too general to have been addressed in an earlier chapter. This chapter then will explore the convenience methods that Prototype adds to built-in objects. Many of them are used within Prototype itself but they re likely to be useful in your own code as well. Using String Methods I m at a loss here. What can I say about strings Strings in JavaScript bear good news and bad news. The bad news is that many of the conveniences that other languages possess for dealing with strings simply aren t present in JavaScript. The good news is that as we ve done elsewhere we can leverage the hackability of the language to fix this shortcoming. String Utility Methods Prototype adds a bagful of useful instance methods to strings. Some you ll use every .