Skip to content

Instantly share code, notes, and snippets.

@serjoscha87
Created September 29, 2016 18:26
Show Gist options
  • Select an option

  • Save serjoscha87/c4bf67f50e468d3576ac9119db565bd9 to your computer and use it in GitHub Desktop.

Select an option

Save serjoscha87/c4bf67f50e468d3576ac9119db565bd9 to your computer and use it in GitHub Desktop.
JS: Messing with other peoples head - or how to complicate a dual switch case
<!-- ... html html html -->
<script src="vendor.js"></script>
<script src="switch.js"></script>
<script src="another_vendor.js"></script>
<script src="switch.js"></script>
<!-- html html html... -->
(function(ⵑⵑ){
ⵑⵑ&&( function(){
console.info("second call of switch.js");
}())||!ⵑⵑ&&( function(){
console.info("first call of switch.js");
}());
}(((window.foo || (window.foo={:0})), window.foo.++)));
/*
This is just a massive (senseless) complicated switch snippet that executes two different parts of code when included two times times
*/
/*
this should make clear what is happening here
*/
(function(switcher){
switcher &&( function(){
console.info("second");
}()) || !switcher && ( function(){
console.info("first");
}());
}(((window.foo || (window.foo={switcher:0})), window.foo.switcher++)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment