Download E-books The Little Book on CoffeeScript PDF

By Alex MacCaw

This concise ebook exhibits JavaScript builders the way to construct significant net functions with CoffeeScript, the amazing language that’s gaining massive curiosity. via instance code, this consultant demonstrates how CoffeeScript abstracts JavaScript, offering syntactical sugar and combating many universal blunders. You’ll study CoffeeScript’s syntax and idioms step-by-step, from easy variables and capabilities to advanced comprehensions and classes.

Written via Alex MacCaw, writer of JavaScript internet functions (O’Reilly), with contributions from CoffeeScript writer Jeremy Ashkenas, this e-book speedy teaches you top practices for utilizing this language—not simply at the customer part, yet for server-side purposes besides. It’s time to take a experience with the little language that could.

  • Discover how CoffeeScript’s syntax differs from JavaScript
  • Learn approximately positive aspects comparable to array comprehensions, destructuring assignments, and classes
  • Explore CoffeeScript idioms and examine them to their JavaScript counterparts
  • Compile CoffeeScript documents in static websites with the Cake construct system
  • Use CommonJS modules to constitution and installation CoffeeScript client-side applications
  • Examine JavaScript’s undesirable parts—including positive aspects CoffeeScript was once in a position to fix

Show description

Read or Download The Little Book on CoffeeScript PDF

Best Programming books

Herb Schildt's C++ Programming Cookbook

Your final "How-To" advisor to C++ Programming! mythical programming writer Herb Schildt stocks a few of his favourite programming recommendations during this high-powered C++ "cookbook. " equipped for fast reference, every one "recipe" exhibits tips on how to accomplish a pragmatic programming activity. A recipe starts off with an inventory of key constituents (classes, services, and headers) via step by step directions that convey tips to gather them right into a whole answer.

Structure and Interpretation of Computer Programs - 2nd Edition (MIT Electrical Engineering and Computer Science)

Constitution and Interpretation of desktop courses has had a dramatic influence on machine technology curricula over the last decade. This long-awaited revision includes adjustments through the textual content. There are new implementations of many of the significant programming structures within the publication, together with the interpreters and compilers, and the authors have included many small alterations that mirror their adventure educating the direction at MIT because the first variation was once released.

Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)

“Every C++ specialist wishes a replica of powerful C++. it really is an absolute must-read for someone taking into account doing severe C++ improvement. If you’ve by no means learn potent C++ and also you imagine you recognize every thing approximately C++, reconsider. ”— Steve Schirripa, software program Engineer, Google “C++ and the C++ group have grown up within the final fifteen years, and the 3rd version of potent C++ displays this.

Software Testing with Visual Studio 2010 (Microsoft Windows Development Series)

Use visible Studio 2010’s step forward trying out instruments to enhance caliber in the course of the whole software program Lifecycle   jointly, visible Studio 2010 final, visible Studio attempt expert 2010, Lab administration 2010, and group beginning Server supply Microsoft builders the main subtle, well-integrated trying out resolution they’ve ever had.

Additional info for The Little Book on CoffeeScript

Show sample text content

Prototype, mixin # utilization comprise Parrot, isDeceased: precise (new Parrot). isDeceased Mixins are a superb development for sharing universal good judgment among modules while inheritance isn't appropriate. the good thing about mixins is for you to comprise a number of ones, in comparison to inheritance the place just one classification might be inherited from. Extending periods Mixins are lovely neat, yet they’re now not very item oriented. as an alternative, let’s combine mixins into CoffeeScript’s periods. We’re going to outline a category known as Module that we will be able to inherit from for mixin aid. Module could have static services, @extend() and @include(), which we will use for extending the category with static and example houses, respectively: moduleKeywords = ['extended', 'included'] category Module @extend: (obj) -> for key, worth of obj whilst key now not in moduleKeywords @[key] = price obj. extended?. apply(@) this @include: (obj) -> for key, worth of obj while key now not in moduleKeywords # Assign houses to the prototype @::[key] = worth 12 | bankruptcy 2: CoffeeScript periods obj. included?. apply(@) this The little dance round the moduleKeywords variable is to make sure we now have callback aid while mixins expand a category. Let’s seriously look into our Module category in motion: classProperties = locate: (id) -> create: (attrs) -> instanceProperties = store: -> category consumer extends Module @extend classProperties @include instanceProperties # utilization: person = person. find(1) consumer = new person consumer. save() As one can find, we’ve further a few static homes, find() and create(), to the consumer category, in addition to an example estate, save(). due to the fact we’ve obtained callbacks at any time when modules are prolonged, we will be able to shortcut the method of employing either static and example houses: ORM = locate: (id) -> create: (attrs) -> prolonged: -> @include keep: -> classification consumer extends Module @extend ORM great basic and stylish! Extending sessions | thirteen CHAPTER three CoffeeScript Idioms each language has a collection of idioms and practices, and CoffeeScript isn't any exception. This bankruptcy will discover these conventions, and convey you a few JavaScript to CoffeeScript comparisons so that you can get a pragmatic feel of the language. every one In JavaScript, to iterate over each merchandise in an array, lets both use the newly additional forEach() functionality, or an outdated C variety for loop. If you’re making plans to exploit a few of JavaScript’s most up-to-date good points brought in ECMAScript five, i counsel you to additionally comprise a shim within the web page to emulate help in older browsers: for (var i=0; i < array. size; i++) myFunction(array[i]); array. forEach(function(item, i){ myFunction(item) }); even if the forEach() syntax is way extra succinct and readable, it suffers from the disadvantage that the callback functionality can be invoked each generation of the array, and is hence a lot slower than the an identical for loop. Let’s see the way it seems to be in CoffeeScript: myFunction(item) for merchandise in array It’s a readable and concise syntax, I’m convinced you’ll agree, and what’s nice is that it compiles to a for loop behind the curtain.

Rated 4.15 of 5 – based on 45 votes