As crockford says “If a value is a function, we can consider it a method”. Let us see a simple example that shows how to use a closure and hide a member.
Any attempt to call deleteEmployee will result in the following error:
Just keep in mind that by doing it this way, it cannot be a part of the prototype. Call it a hack, trick or a hidden feature, nevertheless it is a very useful tip to hide information inside a JavaScript Object!
Tweet
No comments:
Post a Comment