Example of use c preprocessor (cpp)

Why use?

Consider the classic assert macro:

#define assert(x) if(!(x)) { throw new Error("Assertion failed: " + #x) }

Function calls in Javascript can have a significant overhead.
Embedding a calculation inside a macro allows you to avoid a function call.

#define ISCCW(P0, P1, P2) \
     ((P1.x - P0.x) * (P2.y - P0.y) > (P2.x - P0.x) * (P1.y - P0.y))

With the C preprocessor, however, you can juse #ifdef away code not used for production.

#ifdef DEBUG
     function my_test_func() { ... }
#endif // DEBUG