tailieunhanh - JavaScript Bible, Gold Edition part 128
JavaScript Bible, Gold Edition part 128. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1118 Part IV JavaScript Core Language Reference Better ways exist to intercept and preprocess user input but the watch function can be a helpful debugging tool when you want to monitor the hidden workings of scripts. Defining object property getters and setters A future version of the ECMA-262 language specification will likely include a pair of facilities called getter and setter. Until such time as the formal syntax is finalized you can begin to experiment with this technique in NN6 using temporary syntax that adheres to the likely format but intentionally uses different keywords until the standard is adopted . When the standard is adopted a subsequent version of NN will include the standard keywords. I introduced the idea of creating a getter and setter for an object briefly in Chapter 14 where the NN6 syntax style extended properties of some W3C DOM objects to include some of the Microsoft-specific and very convenient DOM syntax. Most notably you can define a getter for any container to return an array of nested elements just like the IE-only collection. The purpose of a getter is to assign a new property to the prototype of an object and to define how the value returned by the property should be evaluated. A setter does the same but it also defines how a new value assigned to the property should apply the value to the object. Both definitions are written in the form of anonymous functions such that reading or writing an object s property value can include sophisticated processing for either operation. Getters and setters are assigned to the prototype property of an object thus enabling you to customize native and DOM objects. The NN6 syntax fashions getters setters and methods of an object s prototype with the following syntax propName function propName function Note that the underscores before and after the method names are actually pairs of underscore characters that is _ _ .
đang nạp các trang xem trước