0

Today i tried coffee script (what a funny name xD),but it doesn't work properly. My script is:

add=(a,b)-> a + b
add 2,2

and it returned this:

(function() {
var add;

add = function(a, b) {
return a + b;
};

add(2, 2);

}).call(this);

This structure of function isn't built properly in my opinion.It begin with a function,and in a function insert another one?And the variable declared in the function are superflue,they work only in the function.And this line:

 .call(this)

what mean? Someone can help me to fix this issue of coffee script please?

  • It is just wrapping your code inside a [closure](http://stackoverflow.com/questions/111102/how-do-javascript-closures-work) – GillesC Jul 28 '15 at 18:34
  • @gillesc: You meant IIFE, not closure – Bergi Jul 28 '15 at 18:35
  • @Bergi No I meant closure, just to annoy the IIFE pedants :) – GillesC Jul 28 '15 at 18:39
  • What can i do now?How it work? – Giovanni Giordano Jul 28 '15 at 18:41
  • @GiovanniGiordano: It *does* work. What do you think would need to be done? What result did you expect? Did you check the duplicate? – Bergi Jul 28 '15 at 18:45
  • @gillesc: Not going to start an argument over [what is a closure](http://stackoverflow.com/a/30252701/1048572) here, but in this case a link to [module IIFE](http://stackoverflow.com/questions/26092101/what-is-this-javascript-pattern-called-and-why-is-it-used) would've helped the OP more than the term "closure" – Bergi Jul 28 '15 at 18:48
  • And now if i want to call my Function,how can i do this?I rapid example please? – Giovanni Giordano Jul 28 '15 at 19:10

0 Answers0