简体   繁体   中英

What means the “->” in node.js

I'm trying to learn about the connect-livereload module and after installing it, is written this :

Next, import:

app.configure 'development', ->
  app.use require('connect-livereload') 35729

is that " -> " sign just a typo or what it stands for ? i would suppose it's just a typo if these two lines weren't chained with just a comma so that's why i ask.

-> is an operator used in CoffeScript .

Functions are defined by an optional list of parameters in parentheses, an arrow, and the function body.

reference at coffescript.com

That's not JavaScript, it's CoffeeScript . It's a function. The JavaScript translation is:

app.configure('development', function() {
    return app.use(require('connect-livereload'), 36729);
});

that is nothing node specific. That code is writting in coffeescript

in javascript that is the same as

app.configure('development', function() {
  return app.use(require('connect-livereload')(35729));
});

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