CoffeeScript is a meta-language which compiles directly into JavaScript, has some neat features and patterns baked in, and is a favorite of many JavaScript hackers, and I’ve been playing around with it in the last few days.
For the most part, I like it, but it steps on one of the most useful features of JavaScript - the var keyword for scope
(
Read more... )
Comments 5
So why would a person use Coffee Script over JavaScript?
Reply
CoffeeScript:
object =
func: -> $('#div').click => @element.css color: 'red'
compiles to JavaScript:
var object;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
object = {
func: function() {
return $('#div').click(__bind(function() {
return this.element.css({
color: 'red'
});
}, this));
}
};
Shorter and quicker to write, easier to scan, with much less boilerplate for doing the same constantly-repeated patterns in javascript.
Reply
Reply
Reply
Leave a comment