Skip to main content
added 86 characters in body
Source Link
konijn
  • 33.8k
  • 5
  • 69
  • 264

You could consider usingcan find inspiration here on how to avoid polluting the global namespace: https://developer.mozilla.org/en-US/docs/Glossary/IIFE#avoid_polluting_the_global_namespace

Your shared JS would be an IIFEstill contain 1 global (the function) that you could call with a config object like

<script>
    initializeMapLogic({
      bgLayerName : '@Model.DefaultBackgroundLayer',
      infoLayerName : '@Model.DefaultInformationLayer',
      onlyEnablePolygon : true,
      allowMultiplePolygons : true
    });
</script>

You could consider using https://developer.mozilla.org/en-US/docs/Glossary/IIFE#avoid_polluting_the_global_namespace

Your shared JS would be an IIFE that you call with a config object like

<script>
    initializeMapLogic({
      bgLayerName : '@Model.DefaultBackgroundLayer',
      infoLayerName : '@Model.DefaultInformationLayer',
      onlyEnablePolygon : true,
      allowMultiplePolygons : true
    });
</script>

You can find inspiration here on how to avoid polluting the global namespace: https://developer.mozilla.org/en-US/docs/Glossary/IIFE#avoid_polluting_the_global_namespace

Your shared JS would still contain 1 global (the function) that you could call with a config object like

<script>
    initializeMapLogic({
      bgLayerName : '@Model.DefaultBackgroundLayer',
      infoLayerName : '@Model.DefaultInformationLayer',
      onlyEnablePolygon : true,
      allowMultiplePolygons : true
    });
</script>
Source Link
konijn
  • 33.8k
  • 5
  • 69
  • 264

You could consider using https://developer.mozilla.org/en-US/docs/Glossary/IIFE#avoid_polluting_the_global_namespace

Your shared JS would be an IIFE that you call with a config object like

<script>
    initializeMapLogic({
      bgLayerName : '@Model.DefaultBackgroundLayer',
      infoLayerName : '@Model.DefaultInformationLayer',
      onlyEnablePolygon : true,
      allowMultiplePolygons : true
    });
</script>