W
W
Wynell_ru2019-06-12 22:16:07
CoffeeScript
Wynell_ru, 2019-06-12 22:16:07

Is it possible to write a function in one line?

Hello.
The question is more theoretical than practical.
Let's say in JavaScript setInterval with console.log:

setInterval(function() {
    console.log("test");
}, 1000);

The same code, but in CoffeeScript:
setInterval ->
    console.log "test"
, 1000

The same code in JavaScript, but in one line:
setInterval(function() {console.log("test");}, 1000);

And finally, the question:
How to implement this in one line in CoffeeScript, and in general, is it possible?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question