Last Updated: February 25, 2016
·
573
· raysrashmi

Beauty of CoffeeScript

Posted a blog about some beautiful code syntax in CoffeeScript which help us to write js code less and pretty

<a href='http://objects.binaryfunction.com/beauty-of-coffeescript'> Beauty of CofeeScript</a>

1 Response
Add your response

Hi Rashmi, I am happy to see you use CoffeeScript for your projects. Couple comments on your blogpost:

Using standalone @ instead of this is generally discouraged in the community.

x if a is on where a is a boolean is an antipattern (as opposed to x if a), unless you are not sure that a is indeed a boolean - it just struck me in the example.

The ?= operator doesn't do what you probably assume it does - it checks the left hand side operand's value for existence and if the value is null or undefined assigns to it the right hand side. The code alert('rays') if(a?=0) would assign to a 0 if a was undefined and then not alert because if evaluates 0 as false. You also don't need the parentheses around the if condition.

Hope this clears some things up! Best of luck in your CoffeeScript ventures!

over 1 year ago ·