Pre-processing Emulator for JavaScript ( Timing / Debug Example )
<p>In C++ you can omit compiling debug code by using pre-processing directives in order to keep your compiled code fast and not hindered by debug code not needed in production.</p>

<p>Is there a correlative way to do this in JavaScript?  What I have been doing in the past is commenting out debug code, but I want a cleaner way to do it.</p>

<p>An example below shows 4 if statements that activate if debug is set to true.  However in production I don't want this checked 4 times when I know it will be set to false.  As I mentioned I could cram it into one line and comment it out...but I want a clean way to do it? </p>

<pre><code>/**
 **  cType
 */

function cType( o_p ) {
    if( debug ) {
        var t1, t2, t3, t4, i1, i2, i3; t1 = new Date().getTime();
    }
    o_p = MType[ o_p.model ].pre( o_p ); 
    if ( o_p.result !== 'complete' ) {
        if( debug ) {
            t2 = new Date().getTime();
            console.log( '---------------Send to Server - object_pipe: \n ' + o_p.toSource() ); 
        } 
        var string_pipe = JSON.stringify( o_p );
        cMachine( 'pipe=' + string_pipe , function( string_pipe ) {
            if( debug ) { 
                console.log( '---------------Receive from Server - object_pipe: \n ' + string_pipe ); 
                t3 = new Date().getTime();
            }
            MType[ o_p.model ].post( JSON.parse( string_pipe ) );
            if( debug ) {
                t4 = new Date().getTime(); i1 = t2-t1 ; i2 = t3-t2 ; i3 = t4-t3;
                console.log( '---------------Pre, Transit, Post = ', i1, i2, i3 );  
            }
        } );
    }
}
</code></pre>
