4 ms·
You shouldn't pollute window with stuff if you don't have to. You created a function called `h` among with a few other things. Otherwise good job making a thin
by mkoryak 3y ago
You shouldn't pollute window with stuff if you don't have to. You created a function called `h` among with a few other things.
Otherwise good job making a thing that has been made many times before
- lioeters 3y agoTo the author, here's a common pattern you can use to avoid defining global variables unless it's needed. ;(function() { const dropzoneDefaults = { ... } class EasyDropzone { ... } const h = function() { ... } // Export to global window.EasyDropzone = EasyDropzone })()
- pazvanti 3y agoThanks. Will definitely try to improve the code. JavaScript is not my main language and I still have many tricks that I should learn.
- lioeters 3y agoHere is some information about this pattern, it's called Immediately Invoked Function Expression. It's a way to create a function scope so that all variables are local, except for any that you want to "export" as a global. https://developer.mozilla.org/en-US/docs/Glossary/IIFE https://developer.mozilla.org/en-US/docs/Glossary/IIFE
- pazvanti 3y agoIt has been made many times, but I could not find something that works easily out of the box. After I made it, decided to share it since others may find it useful.
- jurimasa 3y agoWow. So snarky. Much devel. XD