Tagged Questions
144
votes
5answers
38k views
CoffeeScript & Global Variables
On Coffeescript.org:
bawbag = (x, y) ->
z = (x * y)
bawbag(5, 10)
would compile to:
var bawbag;
bawbag = function(x, y) {
var z;
return (z = (x * y));
};
bawbag(5, 10);
compiling ...
81
votes
7answers
10k views
Has anyone used Coffeescript for a production application? [closed]
Coffeescript looks pretty cool. Has anyone used it? What are its Pros & Cons?
79
votes
7answers
19k views
Can I use CoffeeScript instead of JS for node.js?
What are my restrictions if I want to code node.js and use CoffeeScript?
Can I do anything I'd be able to do in JS?
71
votes
5answers
15k views
how to write setTimeout with params by Coffeescript
Please tell me how to write javascript below in coffeescript.
setTimeout(function(){
something(param);
}, 1000);
71
votes
3answers
9k views
Is there a tool for converting JavaScript to CoffeeScript? [closed]
I'd love to use CoffeeScript, but converting all my JavaScript files doesn't seem like a task I should have to do by hand...
48
votes
8answers
36k views
Clean way to remove element from javascript array (with jQuery, coffeescript)
There are many questions about this, not least:
jQuery version of array contains, a solution with the splice method and many more. However, they all seem complicated and annoying.
With the combined ...
43
votes
3answers
7k views
CoffeeScript. Ternary operation
I need to set value to a that depends on condition.
What is the shortest way to do this with CoffeeScript?
E.g. this is how I'd do it in JavaScript:
a = true ? 5 : 10 # => a = 5
a = false ? 5 : ...
43
votes
4answers
5k views
What does “Splats” mean in the CoffeeScript tutorial?
Looking at this CoffeeScript tutorial : http://jashkenas.github.com/coffee-script/
I don't quite see what the Splats is for. What is this construction? Where does it come from (historically)
40
votes
4answers
14k views
Iterate over associative array in coffeescript
I have an object (an "associate array", also known as a plain Javascript object):
obj = {}
obj["Foo"] = "Bar"
arr["bar"] = "Foo"
and I need to iterate over it using coffeescript. Now, doing like ...
40
votes
17answers
10k views
How can I compile CoffeeScript from .NET?
I want to write an HttpHandler that compiles CoffeeScript code on-the-fly and sends the resulting JavaScript code. I have tried MS [JScript][1] and IronJS without success. I don't want to use ...
39
votes
7answers
3k views
My JavaScript patterns/practices stink. Where should I seek help?
I've been working almost exclusively on back-end tasks for the past few years, and I've just noticed that most JavaScript (and CoffeeScript) projects have got a helluva lot prettier in my absence.
I ...
35
votes
3answers
8k views
Coffeescript - Method chaining with function arguments
What's the best way to chain methods in coffeescript? For example, if I have this javascript how could I write it in coffeescript?
var req = $.get('foo.htm')
.success(function( response ){
// ...
33
votes
2answers
9k views
require()'ing a CoffeeScript file from a JavaScript file or REPL
I'm using Node.js and wanting to incorporate CoffeeScript into my workflow. I have two use-cases:
I want to be able to write JavaScript files which require() CoffeeScript modules
I want to be able ...
32
votes
7answers
8k views
Writing a jquery plugin in coffeescript - how to get “(function($)” and “(jQuery)”?
I am writing a jquery plugin in coffeescript but am not sure how to get the function wrapper part right.
My coffeescript starts with this:
$.fn.extend({
myplugin: ->
@each ->
...
30
votes
3answers
5k views
Coffeescript — How to create a self-initiating anonymous function?
How to write this in coffeescript?
f = (function(){
// something
})();
Thanks for any tips :)