如何在 JavaScript 中模拟宏?
我知道 JavaScript 不支持宏(Lisp 风格的),但我想知道是否有人有解决方案来模拟宏?我用谷歌搜索了一下,其中一种解决方案建议使用 eval()
,但正如他所说,成本会很高.
I know that JavaScript doesn't support macros (Lisp-style ones) but I was wondering if anyone had a solution to maybe simulate macros? I Googled it, and one of the solutions suggested using eval()
, but as he said, would be quite costly.
他们真的不必很花哨.我只想和他们做一些简单的事情.而且它不应该使调试变得更加困难:)
They don't really have to be very fancy. I just want to do simple stuff with them. And it shouldn't make debugging significantly harder :)
推荐答案
你可以使用 parenscript.这将为您提供 Javascript 的宏.
You could use parenscript. That'll give you macros for Javascript.
相关文章