简体   繁体   中英

Embedding coffeescript … in Javascript?

Within the current codebase of javascript code, I would like to be able to incrementally replace functions/blocks using cleaner and compact coffeescript, and add new code using coffeescript.

  1. Is it a good practice? (In fact, shouldn't this be a default approach?)
  2. I need a utility to convert javascript with embedded coffeescript into javascript, and well integrated into node.js environment?

Javascript到Coffee-script双向转换器

I am not exactly sure what you mean by "javascript with embedded coffeescript", but nonetheless, here is my advice:

1) Use Grunt to compile your coffeescript into javascript whenever you save a file ( and also have Grunt do other sutff for you )

2) Do all new development in coffeescript. Once you go coffeescript, you never want to go back. It's just better, and there really is no downside.

If the objective is to use some language that is concise and to incrementally update your existing Javascript code to that language than Microsoft's TypeScript might be a better choice than CoffeeScript. Typecript lets you mix JavaScript and Typescript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM