macro definition in javascript

后端 未结 6 711
一向
一向 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 23:02

    With Builder – https://github.com/electricimp/Builder, you can do like:

    @macro MYDEBUG(x)
      debug(@{__FILE__}, @{x});
    @end
    
    ...
    
    @{MYDEBUG(100500)}
    

    Also supports for includes directly from GitHub.

提交回复
热议问题