CoffeeScript Undefined
Finally I found this easy way to do it: if (MyVariable?){ … } that will generate: if (typeof MyVariable !== “undefined” && MyVariable !== null){ … } UPDATE 04/07/2014 Demo Link
Finally I found this easy way to do it: if (MyVariable?){ … } that will generate: if (typeof MyVariable !== “undefined” && MyVariable !== null){ … } UPDATE 04/07/2014 Demo Link
Yup: passwordNotEmpty = not not password or shorter: passwordNotEmpty = !!password
We’ve started to use CoffeeScript in our product – a non-public facing website which is basically an app for browsing certain kinds of data. We use CoffeeScript as a command-line compiler (not on the server, which we’d eventually like to do). PROS (for us): It gets rid of a lot of needless clutter in javascript … Read more
RequireJS does everything you need. My answer to this question may help you. Example: Client app project hierarchy: sampleapp |___ main.js |___ cs.js |___ require.js main.js is where you initialize your client application and configure RequireJS: require.config({ baseUrl: “/sampleapp”, paths: { jquery: “libs/jquery”, // Local underscore: “http://underscorejs.org/underscore-min.js”, // Remote backbone: “https://github.com/documentcloud/backbone/blob/master/backbone-min.js” // Remote on GitHub … Read more
Good old push still works. x = [] x.push ‘a’
Simple — place a comma by itself in a column lower than that in which you define your objects. a = [ nameA1: valueA1 nameA2: valueA2 nameA3: valueA3 , nameB1: valueB1 nameB2: valueB2 nameB3: valueB3 ] Will become: var a; a = [ { nameA1: valueA1, nameA2: valueA2, nameA3: valueA3 }, { nameB1: valueB1, nameB2: … Read more
React events are actually Synthetic Events, not Native Events. As it is written here: Event delegation: React doesn’t actually attach event handlers to the nodes themselves. When React starts up, it starts listening for all events at the top level using a single event listener. When a component is mounted or unmounted, the event handlers … Read more
key of obj This compiles to JavaScript’s key in obj. (CoffeeScript uses of when referring to keys, and in when referring to array values: val in arr will test whether val is in arr.) thejh’s answer is correct if you want to ignore the object’s prototype. Jimmy’s answer is correct if you want to ignore … Read more
The term “splat operator” comes from Ruby, where the * character (sometimes called the “splat”—see the Jargon File entry) is used to indicate that an entry in an argument list should “soak up” a list of arguments. CoffeeScript adopted Ruby-style splats very early on (see issue 16), but at Douglas Crockford’s suggestion, the syntax was … Read more
UPDATE: See my other answer to this question, How can I compile CoffeeScript from .NET? for a far more accurate and up-to-date list of the current options. CoffeeScript-Compiler-for-Windows works well.