I am not sure how to write this in CS. maybe some1 can help:
FB.getLoginStatus(function (response) {} , {scope : scope})
thanks.
You would write some CoffeeScript like so...
FB.getLoginStatus(
(response) ->
doSomething()
{scope: scope})
Which would convert to the JavaScript like so...
FB.getLoginStatus(function(response) {
return doSomething();
}, {
scope: scope
});
FB.getLoginStatus(function(response) {}, {
scope: scope
});
in JavaScript is:
FB.getLoginStatus(
(response) ->
{ scope }
)
in CoffeeScript.
To answer your question about multiple parameters further have a look at these examples:
$('.main li').hover(
-> $(@).find('span').show()
-> $(@).find('span').hide()
)
In CoffeeScript equals to:
$('.main li').hover(function() {
return $(this).find('span').show();
}, function() {
return $(this).find('span').hide();
});
in JavaScript.
An even simpler example regarding handling multiple parameters (without anonymous functions) would be:
hello = (firstName, lastName) ->
console.log "Hello #{firstName} #{lastName}"
hello "Coffee", "Script"
in CoffeeScript compiles to:
var hello;
hello = function(firstName, lastName) {
return console.log("Hello " + firstName + " " + lastName);
};
hello("Coffee", "Script");
in JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With