Consider the following:
https://developer.mozilla.org/en-US/docs/Glossary/IIFE
(function() {}());
Then there is this snippet:
class Test {
constructor() {
this.WP = (() => { //scope here?
// annotated
const tar = webpackJsonp.push([[], {a_test: (md, exp, tar) => md.exports = tar}, [["a_test"]]]);
delete tar.m.a_test;
delete tar.c.a_test;
// annotated_end
const find = (mask) => {
for (let i in tar.c) {
if (tar.c.hasOwnProperty(i)) {
let m = tar.c[i].exports;
if (m && m.__esModule && m.default && mask(m.default)) return m.default;
if (m && mask(m)) return m;
}
}
return null;
};
return {find};
})();
}
}
Which is
= (() => {})();
My understanding they are both IIFE, what I don't understand is:
- Why such difference in syntax? I'm not talking about arrow part, I know about arrow functions. I'm talking about brackets, there is some scope nonsense.
- Why annotated part executes only once?
const tar
is scoped and this is a function and each time I call it the scope should be reinstated. Yet callingfind
reuses already existingconst
variable. What gives?
I Honestly Am Totally Enigmatically Just Stumbled