Created
          June 27, 2013 09:41 
        
      - 
      
- 
        Save meeDamian/5875254 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // dodajesz gdzieś raz do bibliotek | |
| function goforit() { | |
| if( active ) { | |
| var args = Array.prototype.slice.call(arguments, 0); | |
| (args.shift()).apply(null, args); | |
| } | |
| return active; | |
| } | |
| // funkcje do uruchomienia | |
| function fun1( a, b ) { | |
| console.log("f1", a, b, a+b); | |
| } | |
| function fun2( c, d ) { | |
| console.log("f2", Math.pow(c,d)); | |
| } | |
| // wylosuj stan: true|false | |
| var active = !!Math.round(Math.random()); | |
| // stare podejście: | |
| (function oldWay() { | |
| if( active ) fun1( 7, 5 ); | |
| // do sth else | |
| if( active ) fun2( 4, 3 ); | |
| })(); | |
| // nowe podejście: | |
| (function newWay() { | |
| goforit( fun1, 7, 5 ); | |
| // do sth else | |
| goforit( fun2, 4, 3 ); | |
| })(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment