Why does Google's closure library not use real private members?

Posted by Thor Thurn on Stack Overflow See other posts from Stack Overflow or by Thor Thurn
Published on 2010-04-03T18:40:11Z Indexed on 2010/04/03 18:43 UTC
Read the original article Hit count: 437

Filed under:

I've been a JavaScript developer for a while now, and I've always thought that the correct way to implement private members in JavaScript is to use the technique outlined by Doug Crockford here: http://javascript.crockford.com/private.html.

I didn't think this was a particularly controversial piece of JavaScript wisdom, until I started using the Google Closure library. Imagine my surprise... the library makes no effort to use Crockford-style information hiding. All they do is use a special naming convention and note "private" members in the documentation. I'm in the habit of assuming that the guys at Google are usually on the leading edge of software quality, so what gives? Is there some downside to following Mr. Crockford's advice that's not obvious?

© Stack Overflow or respective owner

Related posts about JavaScript