0

Can someone please explain what this name spacing is doing?

app.framework.superNav = {};
(function (superNav, $) {
 // code
})(app.framework.superNav, jQuery);
  • You should tag this with jQuery as well. – SudoKid Mar 28 '19 at 17:01
  • This is not a jQuery question. It's an IIFE/scope question – Taplar Mar 28 '19 at 17:01
  • It's doing nothing except allowing you to use `superNav` to access `app.framework.superNav` variable and `$` for `jQuery` for your `// code`. How it is defined, you still could use the original variables inside, though (unless they are removed afterwards) – Kaddath Mar 28 '19 at 17:09
  • Also relevant: https://stackoverflow.com/questions/111102/how-do-javascript-closures-work – VLAZ Mar 28 '19 at 17:09
  • _"Possible duplicate of What is the (function() { } )() construct in JavaScript"_ no he isn't asking that. – Vinay Mar 28 '19 at 17:22

0 Answers0