Download E-books The Little Book on CoffeeScript PDF

By Alex MacCaw

This little booklet exhibits JavaScript builders easy methods to construct amazing internet functions with CoffeeScript, the extraordinary little language that’s gaining significant curiosity. via instance code, this consultant demonstrates how CoffeeScript abstracts JavaScript, offering syntactical sugar and combating many universal error. You’ll examine CoffeeScript’s syntax and idioms step-by-step, from uncomplicated variables and services to complicated comprehensions and classes.

Written by means of Alex MacCaw, writer of JavaScript internet functions (O’Reilly), with contributions from CoffeeScript author Jeremy Ashkenas, this publication fast teaches you most sensible practices for utilizing this language—not simply at the shopper aspect, yet for server-side purposes besides. It’s time to take a experience with the little language that could.
* notice how CoffeeScript’s syntax differs from JavaScript
* know about beneficial properties resembling array comprehensions, destructuring assignments, and sessions
* discover CoffeeScript idioms and evaluate them to their JavaScript opposite numbers
* assemble CoffeeScript documents in static websites with the Cake construct procedure
* Use CommonJS modules to constitution and installation CoffeeScript client-side purposes
* research JavaScript’s undesirable parts—including gains CoffeeScript used to be in a position to repair

Show description

Read Online or Download The Little Book on CoffeeScript PDF

Similar Javascript books

JavaScript: A Beginner's Guide, Fourth Edition

Absolutely up-to-date for the most recent JavaScript typical and that includes a brand new bankruptcy on HTML5 and jQuery JavaScript: A Beginner's consultant indicates the best way to create dynamic web content whole with lighting tricks utilizing modern major net improvement language. With the expansion of HTML five, JavaScript is anticipated to develop much more to script the canvas point, upload drag and drop performance, and extra.

Lean Websites

A pragmatic ebook on site functionality for net builders, concentrating usually on front-end functionality development. It covers lots of stable concept, yet is additionally full of important, genuine global tricks and tips so you might use in your websites this present day. issues lined comprise: person event, layout and performanceMeasuring and tracking performanceSetting up a web page weight budgetNetwork and server improvementsOptimizing photographs and videoOptimizing scripts and 3rd celebration contentLean DOM operations The booklet additionally comes with a convenient "cheat sheet" summarizing the various key guidance contained in the e-book.

Pro Android Web Apps: Develop for Android using HTML5, CSS3 & JavaScript (Books for Professionals by Professionals)

Constructing purposes for Android and different cellular units utilizing net applied sciences is now good nearby. whilst the functions of HTML5 are mixed with CSS3 and JavaScript, net software builders have a chance to advance compelling cellular purposes utilizing frequent instruments. not just is it attainable to construct cellular internet apps that believe nearly as good as local apps, yet to additionally write an software as soon as and feature it run various various units.

Foundation HTML5 Animation with JavaScript

Starting place HTML5 Animation with JavaScript covers every little thing that you have to comprehend to create dynamic scripted animation utilizing the HTML5 canvas. It offers details on the entire proper math you will want, earlier than relocating directly to physics strategies like acceleration, speed, easing, springs, collision detection, conservation of momentum, 3D, and ahead and inverse kinematics.

Extra resources for The Little Book on CoffeeScript

Show sample text content

Is your favourite colour? Galahad: #{favorite_color} Bridgekeeper: incorrect! " As you'll find during this instance, multiline strings also are allowed, with no need to prefix each one line with a +. Loops and Comprehensions Array new release in JavaScript has a slightly archaic syntax, similar to an older language like C instead of a contemporary object-orientated one. The advent of ES5 more desirable that state of affairs a bit of, with the forEach() functionality, yet that also calls for a functionality name each generation and is for this reason a lot slower. back, CoffeeScript involves the rescue, with a stunning syntax: for identify in ["Roger", "Roderick", "Brian"] alert "Release #{name}" if you would like the present new release index, simply go an additional argument: for identify, i in ["Roger the pickpocket", "Roderick the robber"] alert "#{i} - free up #{name}" you can even iterate on one line, utilizing the postfix shape: free up prisoner for prisoner in ["Roger", "Roderick", "Brian"] As with Python comprehensions, you could filter out them: prisoners = ["Roger", "Roderick", "Brian"] free up prisoner for prisoner in prisoners whilst prisoner[0] is "R" you may as well use comprehensions for iterating over homes in items. rather than the in key-phrase, use of: names = sam: seaborn, donna: moss alert("#{first} #{last}") for first, final of names the single low-level loop that CoffeeScript exposes is the whereas loop. This has related habit to the whereas loop in natural JavaScript, yet has the further virtue that it returns an array of effects (i. e. just like the Array. prototype. map() function): num = 6 minstrel = whereas num -= 1 num + " courageous Sir Robin ran away" Arrays CoffeeScript takes suggestion from Ruby in terms of array cutting by utilizing levels. levels are created by way of numerical values, the 1st and final positions within the variety, separated by way of .. or .... If a spread isn’t prefixed via something, CoffeeScript expands it out into an array: variety = [1.. five] If, even if, the variety is specific instantly after a variable, CoffeeScript converts it right into a slice() technique name: firstTwo = ["one", "two", "three"][0.. 1] within the instance above, the variety returns a brand new array, containing basically the 1st parts of the unique array. you may also use an analogous syntax for changing an array section with one other array: numbers = [0.. nine] numbers[3.. five] = [-3, -4, -5] What’s neat, is that JavaScript helps you to name slice() on strings too, so that you can use levels with string to come back a brand new subset of characters: my = "my string"[0.. 1] Checking to determine if a price exists inside of an array is often a bore in JavaScript, quite simply because indexOf() doesn’t but have complete cross-browser help (Internet Explorer, I’m speaking approximately you). CoffeeScript solves this with the in operator, for instance: phrases = ["rattled", "roudy", "rebbles", "ranks"] alert "Stop wagging me" if "ranks" in phrases Aliases and the Existential Operator CoffeeScript contains a few helpful aliases to avoid wasting typing. One such alias is @, which might be utilized in position of this: @saviour = actual one other is ::, that is an alias for prototype: User::first = -> @records[0] utilizing if for null tests in JavaScript is usual, yet has a couple of pitfalls in that vacant strings and 0 are either coerced into fake, that may trap you out.

Rated 4.04 of 5 – based on 50 votes