coffeescript

Páginas: 44 (10970 palabras) Publicado: 29 de junio de 2014
CoffeeScript
Un pequeño gran libro
Javi Jimenez
Este libro está a la venta en http://leanpub.com/coffeescript
Esta versión se publicó en 2013-12-17

This is a Leanpub book. Leanpub empowers authors and
publishers with the Lean Publishing process. Lean Publishing is
the act of publishing an in-progress ebook using lightweight tools
and many iterations to get reader feedback, pivot untilyou have
the right book and build traction once you do.

This work is licensed under a Creative Commons
Attribution-NonCommercial-NoDerivs 3.0 Unported License

¡Twitea sobre el libro!
Por favor ayuda a Javi Jimenez hablando sobre el libro en Twitter!
El hashtag sugerido para este libro es #librocoffeescript.
Descubre lo que otra gente está diciendo sobre el libro haciendo
click en esteenlace para buscar el hashtag en Twitter:
https://twitter.com/search?q=#librocoffeescript

Dedicado a todas las personas que me sufren día a día.

Índice general
Agradecimientos . . . . . . . . . . . . . . . . . . . . . . . .

1

Prefacio . . . . . . . . . . . . . .
JavaScript, El lenguaje padre .
CoffeeScript, El hijo bastardo
Un libro por el mundo . . . .

.
.
.
.

.
.
..

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

2
3
4
5

1. Comenzando . . . . . . .
1.1 Entorno necesario . . .
1.2 Instalando NodeJS . . .
1.3 Instalando CoffeeScript

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
..

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

7
7
8
11

2. Sintaxis . . . . . . . . . . . . . . . .
2.1 Valores, variables y comentarios
2.2 Interpolación de cadenas . . . .
2.3 Control de flujo . . . . . . . . .
2.4 Loops . . . . . . . . . . . . . .
2.5 Alias y Operadores . . . . . . .

.
.
.
.
..

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

13
13
15
16
18
22

3. Funciones, Ámbito y Contexto . . .
3.1 Funciones . . . . . . . . . . . . .
3.2 Funciones y Argumentos . . . . .
3.3 Llamando a funciones . . .. . . .
3.4 Ámbito . . . . . . . . . . . . . . .
3.5 Contexto . . . . . . . . . . . . . .
3.6 Cambio de contexto en funciones

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

26
26
27
3133
36
39

.
.
.
.

.
.
.
.

ÍNDICE GENERAL

4. Objetos y Arrays . . . . . . . . . . . . .
4.1 Recordando JavaScript y sus Objetos .
4.2 Objetos . . . . . . . . . . . . . . . . .
4.3 Arrays . . . . . . . . . . . . . . . . .
4.4 Comprensiones . . . . . . . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
..
.

.
.
.
.
.

.
.
.
.
.

41
41
42
45
50

5. Clases . . . . . .
5.1 Prototipos . .
5.2 Clases . . . .
5.3 Herencia . . .
5.4 Polimorfismo

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
..

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

52
52
55
58
61

6. Modularización . . . .
6.1 Namespacing . . .
6.2 Mixins . . . . . . .
6.3 Extendiendo clases

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
....
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS