Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coffeescript . for/in loop

Tags:

Anybody knows if it is possible to get a

javascript for/in loop

from coffeescript?

Actually would like to write the js function

function logobject(o) {
   for (p in o)
     console.log(p + "=" + o[p])
}

in coffeescript.

like image 718
citykid Avatar asked Jun 14 '12 21:06

citykid


People also ask

Is CoffeeScript still a thing?

As of today, January 2020, CoffeeScript is completely dead on the market (though the GitHub repository is still kind of alive).

What is CoffeeScript used for?

CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehension and destructuring assignment.

Is CoffeeScript easy?

CoffeeScript is a lightweight language that compiles into JavaScript. It provides simple and easy to learn syntax avoiding the complex syntax of JavaScript.

How do you write a CoffeeScript?

In general, we use parenthesis while declaring the function, calling it, and also to separate the code blocks to avoid ambiguity. In CoffeeScript, there is no need to use parentheses, and while creating functions, we use an arrow mark (->) instead of parentheses as shown below.


1 Answers

console.log "#{k}=#{v}" for k, v of o
like image 121
Pickels Avatar answered Sep 28 '22 08:09

Pickels