macro definition in javascript

后端 未结 6 729
一向
一向 2021-01-01 22:07

Is there a way that I can define a macro similar to C/C++ macros in Javascript?

I want to use this for debug statements: Something like

#ifdef TEST         


        
6条回答
  •  孤独总比滥情好
    2021-01-01 22:56

    While is true that there is no compile time as @sapht said, you can pre-process your files if you want. Typically I use an ant script to combine many Javascript files together and add build information.

    From a google search I see there is a Javascript preprocessor that you may find interesting: http://www.bramstein.com/projects/preprocess/

提交回复
热议问题