This is the code (specifically, 398 to 407):
https://github.com/openexchangerates/accounting.js/blob/master/accounting.js#L403
I don't understand this method:
// Use accounting.noConflict to restore `accounting` back to its original value.
// Returns a reference to the library's `accounting` object;
// e.g. `var numbers = accounting.noConflict();`
lib.noConflict = (function(oldAccounting) {
return function() {
// Reset the value of the root's `accounting` variable:
root.accounting = oldAccounting;
// Delete the noConflict method:
lib.noConflict = undefined;
// Return reference to the library to re-assign it:
return lib;
};
})(root.accounting);
If I do var numbers = accounting.noConflict()
, it puts the library in the numbers variable. What I don't understand is, why if I do numbers.noConflict
it is undefined. I know lib.noConflict = undefined
sets it to undefined
, but isn't it then set to lib
since the following code is return lib
?