I'm porting over my UI-heavy app from JS to CS this week. The problem with CS is that there's just not enough tutorials/documentation online yet so articles like this are quite welcome. Here's a list of random CS things that took me a little figuring out:
1. Every function returns the last operation. To not return anything, insert a blank 'return' at the end.
2. Descending ranges just work: [10..0]
3. You can use if(`regular JS between backticks`) / else
4. You don't need node.js to compile CS (or LessJS)*
5. Don't expect a 1-to-1 conversion between old JS and new CS. CS loops have lots of smart-things built-in and will look different but work just the same or better once you know what you're doing.
* CS and Less both have JS functions that accept a raw string and output compiled string. On OSX, you can use jsc + little bit of bash to compile CS and Less to JS and CSS respectively. It is such a pleasure to work in CS and Less, especially since I know the end result is clean, standard JS/CSS that works everywhere.
1. Every function returns the last operation. To not return anything, insert a blank 'return' at the end.
2. Descending ranges just work: [10..0]
3. You can use if(`regular JS between backticks`) / else
4. You don't need node.js to compile CS (or LessJS)*
5. Don't expect a 1-to-1 conversion between old JS and new CS. CS loops have lots of smart-things built-in and will look different but work just the same or better once you know what you're doing.
* CS and Less both have JS functions that accept a raw string and output compiled string. On OSX, you can use jsc + little bit of bash to compile CS and Less to JS and CSS respectively. It is such a pleasure to work in CS and Less, especially since I know the end result is clean, standard JS/CSS that works everywhere.