Reading Pro JavaScript's second chapter "Object-Oriented JavaScript" reminded me that I do not use the prototype property to add public methods to a JavaScript object. I use "Privileged Methods" (pg 36) instead.
In the book, John refers to Douglas Crockford's JavaScript site and the Privileged technique described in the web page titled Private Members in JavaScript. I quote from the web page:
If you are looking for more code examples beyond what Douglas Crockford provides, Quizzpot shows more code examples at Private and privileged methods in JavaScript
"A privileged method is able to access the private variables and methods, and is itself accessible to the public methods and the outside."
If you are looking for more code examples beyond what Douglas Crockford provides, Quizzpot shows more code examples at Private and privileged methods in JavaScript
Using Privileged Methods is a great technique when coding JavaScript objects. Have fun doing it.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.