I am trying to learn the real detailed details of Javascript, so I would appreciate it if anyone could explain this code to me. In ColorBox, the author defines his public method as follows:
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
};
Then, other public methods are defined, such as:
publicMethod.remove = function () {
};
In practice, I know that this function can then be called as $ .colorbox () and $ .colorbox.remove (), but I'm a bit confused by the actual syntax. In particular, what happens when he assigns "$. Fn [colorbox]" and "$ [colorbox]" to publicMethod?
Do you have any comments on this code? Is this a good design? Are there any other patterns you would recommend?
source
share