Posted 7 months ago. Visible to the public. Repeats.

Operators "in" and "of" are very inconsistent between CoffeeScript and JavaScript

CoffeeScript and JavaScript (ECMAScript) both have operators in and of. Each language use them for more than one purpose. There is not a single case where the same operator can be used for the same purpose in both languages.

Check if an object (or its prototype) has a property

CoffeeScript

Copy
var hasFoo = 'foo' of object

JavaScript

Copy
var hasFoo = 'foo' in object;

Iterate through all properties of an object

CoffeeScript

Copy
object = { ... } for key, value of object console.log("key %o has value %o", key, value);

JavaScript

Copy
var object = { ... }; for (var key in object) { var value = x[key]; console.log("key %o has value %o", key, value); }

Iterate through all values of an array

CoffeeScript

Copy
array = [...] for entry in array console.log("value is %o", entry.value)

JavaScript

Copy
var array = [...] for (var entry of array) { console.log("value is %o", value); })

Iterate through all values of an iterator

CoffeeScript

Copy
iterator = ... while entry = iterator.next() && !entry.done console.log("value is %o", entry.value)

JavaScript

Copy
var iterator = ...; for (var value of iterator) { console.log("value is %o", value); }

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Henning Koch
Last edit:
7 months ago
by Florian Leinsinger
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more