This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
app = express(), | |
// ... | |
passport = require('passport'), | |
MongoStore = require('connect-mongo')(express), | |
Flash = require('connect-flash'); | |
// View stuff | |
app.configure(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
angular | |
.module('acamica.admin') | |
.factory('AdminLessonResourceModel', AdminLessonResourceModelFactory); | |
/** | |
* @ngdoc service | |
* @name acamica.admin.factory:AdminLessonResourceModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
// let vs const | |
var miNumero = 9 | |
miNumero++; | |
// Constante !== Inmutable | |
var miObjeto = { | |
numero: 9 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript | |
// Tipos implicitos | |
let miNum = 9; | |
miNum = 10; | |
// Tipos explicitos | |
let miStr; | |
miStr = 'Hola' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
function Perro (nombre) { | |
this.nombre = nombre; | |
} | |
Perro.prototype.hablar = function () { | |
console.log('woof'); | |
// console.log('woof, soy', this.nombre); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript | |
class Perro { | |
constructor (nombre) { | |
// this.nombre = nombre; | |
} | |
hablar () { | |
console.log('woof'); | |
// console.log('woof, soy', this.nombre); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript | |
let usuario1; | |
usuario1.nombre = 'Jose'; | |
usuario1.apellido = 'Perez' | |
ajax('http://mi-api.com/getUser') | |
.then(usuario => console.log(`nombre: ${usuario.nombres}`)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ordenarPorNombre(a) { | |
var resultado = a.slice(0); | |
resultado.sort(function(x, y) { | |
return x.nombre.localCompare(y.nombre); | |
}); | |
return resultado; | |
} | |
// const resultado = ordenarPorNombre() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Refactoring | |
function miFnLoca(personas) { | |
personas.forEach(function (p) { | |
console.log('nombre: ', p); | |
}); | |
} | |
miFnLoca(['Jose', 'Pedro']); | |
miFnLoca('Mariano'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript | |
// Habilitar no implicit any y strict null check | |
interface IUser { | |
nombre: string; | |
} | |
function getUser(cb) { | |
// ... | |
cb(null, { nombre: 'Hernan' }) |
OlderNewer