I've seen some NodeJS code examples on a couple of tech-blog sites with strange syntax. Have I been living under a rock or is this just the Syntax Highlighter playing silly buggers?
Example:
module.exports = (app) ->
app.get '/', (req, res) ->
res.send('hello world')
I presume the fact that this is an Express app is academic. Be gentle with your answers...
That’s not JavaScript; that’s CoffeeScript! You’re not missing anything… in every sense.
(CoffeeScript’s npm package lets you run CoffeeScript under Node using coffee.)
The example code you have posted is CoffeeScript, a Ruby/Python-like language that compiles directly to JavaScript. Here is an equivalent in JavaScript:
module.exports = function (app) {
app.get('/', function (req, res) {
res.send('hello world');
});
};