Skip to content

Instantly share code, notes, and snippets.

View hrajchert's full-sized avatar
🎯
Focusing

Hernan Rajchert hrajchert

🎯
Focusing
View GitHub Profile
var express = require('express'),
app = express(),
// ...
passport = require('passport'),
MongoStore = require('connect-mongo')(express),
Flash = require('connect-flash');
// View stuff
app.configure(function(){
(function() {
'use strict';
angular
.module('acamica.admin')
.factory('AdminLessonResourceModel', AdminLessonResourceModelFactory);
/**
* @ngdoc service
* @name acamica.admin.factory:AdminLessonResourceModel
// ES6 (arrow function)
var miArray = [1, 2, 3];
miArray
// mas corta
.map(function (v) {
return v * 2;
})
// Con parentesis
.filter(function (v) {
return v > 3;
// ES6
// let vs const
var miNumero = 9
miNumero++;
// Constante !== Inmutable
var miObjeto = {
numero: 9
};
// ES6
function Perro (nombre) {
this.nombre = nombre;
}
Perro.prototype.hablar = function () {
console.log('woof');
// console.log('woof, soy', this.nombre);
};
// TypeScript
// Tipos implicitos
let miNum = 9;
miNum = 10;
// Tipos explicitos
let miStr;
miStr = 'Hola'
// TypeScript
class Perro {
constructor (nombre) {
// this.nombre = nombre;
}
hablar () {
console.log('woof');
// console.log('woof, soy', this.nombre);
// TypeScript
let usuario1;
usuario1.nombre = 'Jose';
usuario1.apellido = 'Perez'
ajax('http://mi-api.com/getUser')
.then(usuario => console.log(`nombre: ${usuario.nombres}`))
function ordenarPorNombre(a) {
var resultado = a.slice(0);
resultado.sort(function(x, y) {
return x.nombre.localCompare(y.nombre);
});
return resultado;
}
// const resultado = ordenarPorNombre()
// Refactoring
function miFnLoca(personas) {
personas.forEach(function (p) {
console.log('nombre: ', p);
});
}
miFnLoca(['Jose', 'Pedro']);
miFnLoca('Mariano');