What's the point of initializing a variable with the same value twice?

Posted by JoeM05 on Programmers See other posts from Programmers or by JoeM05
Published on 2011-11-29T19:11:27Z Indexed on 2011/11/30 10:32 UTC
Read the original article Hit count: 191

Filed under:
|

I was reading Ben Cherry's "JavaScript Module Pattern: In-Depth", and he had some example code that I didn't quite understand. Under the Cross-File Private State heading, there is some example code that has the following:

var _private = my._private = my._private || {}

This doesn't seem to be different from writing something like this:

var _private = my._private || {}

What's happening here and how are these two declarations different?

© Programmers or respective owner

Related posts about JavaScript

Related posts about syntax