I have a function onChangeBrand() in A.js and there is a same name in B.js.
So how to avoid this situation? There is a constraint - I can't change the function names. and i am not allowed to edit both the Js files so namespace is not a right idea for me.
Can we call something like A.onChangeBrand() or B.onChangeBrand()?
Ok, if namespaces are not for you and you can put your code in between the script tags loading these files
<script src='a.js'></script>
<script>
var a_onChangeBrand = onChangeBrand; // copy the function
</script>
<script src='b.js'></script>
after that a_onChangeBrand() will call the function from a.js and onChangeBrand() from b.js
But nothing will help you if some functions in those a.js and b.js are also using these functions - they might call function from the last file loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With