Node.js is a JavaScript runtime built on Chrome's JavaScript engine for building fast and scalable network applications. It uses non-blocking I/O and event-driven architecture, making it suitable for real-time applications with many simultaneous connections. The document provides an example of an HTTP server in Node.js and discusses key aspects of the platform like the event loop, modules, and package management with npm. It also introduces Express.js as a popular web framework built on Node.js that simplifies building web servers.
11. - lenguaje que compila a javascript.
- es directamente compatible con librerías.
javascript (y vice-versa).
- sintaxis bonita. :D
- tiene su propia consola para node.
12. numero = 15
numeros = [1, 2, 3]
nombres = [
'Santi'
'Miguel'
'Mati'
]
cuadrado = (x) ->
x * x
mate =
cuadrado: (x) ->
x * x
cubo: (x) ->
x * cuadrado x
if numero > 10
console.log "Un numero: #{numero}"
console.log("Un numero: #{numero}") if numero > 10
var numero = 15;
var numeros = [1, 2, 3];
var nombres = ['Santi',
'Miguel',
'Mati'];
var cuadrado = function(x) {
return x * x
};
var mate = {
cuadrado: function(x) {
return x * x
},
cubo: function(x) {
return x * cuadrado(x);
}
};
if (numero > 10) {
console.log("Un numero: " + numero);
};
Javascript Coffeescript
13. Clases
class WinConditionRow
constructor: (rowNumber) ->
@rowNumber = rowNumber
hasWon: (board, player) ->
board[@rowNumber].every (cell) ->
cell == player
winCondition = new WinConditionRow(1)
winCondition.hasWon(board, player)
class Persona
constructor: (nombre, apellido) ->
@nombre = nombre
@apellido = apellido
obtenerNombreCompleto: ->
"#{@nombre} #{@apellido}"
class Doctor extends Persona
obtenerNombreCompleto: ->
"Dr. #{super()}"
14. Listas y bucles
num for num in [1..10]
game.getId() for game in games when game.isFinished()
for game in games
do (game) ->
game.play player, 0, 0
console.log game.getBoard()
15. ExpressJS
- framework web similar a Sinatra.
- super minimalista y modular.
express = require 'express'
app = express()
app.get '/', (req, res) ->
res.send 'Hello World!'
app.listen 3000